輪播功能邏輯正常,但每張圖片只顯示一半,懷疑 CSS 樣式衝突導致容器尺寸計算錯誤。
overflow: hidden,導致圖片超出可視區。
.carousel-container { height: 400px; overflow: hidden; position: relative; }
img { max-width: 100%; height: auto; } 影響輪播內圖片縮放。
.carousel img { max-width: none; width: 100%; height: 100%; object-fit: cover; }
<link rel="stylesheet" href="jquery.carousel.css">
<link rel="stylesheet" href="custom.css"> /* 後載入可覆蓋 */
@media 規則。width/height 來源。若自行修復困難,可嘗試成熟插件: