因此,我創建了一個從左向右滾動的畫廊。我想要做的是讓div將圖片大小調整爲圖片的合併寬度,以便您不能將最終圖片滾動到虛無。目前我有一個固定的寬度。與inline-block的更換,這並不工作(也許是因爲從.country_holder 70%的寬度被強迫阻止行爲?)這是我當前的代碼:將div調整爲包含圖像的寬度
<ul>
<li class="country_holder" id="c_scotland">
<div class ="g_title" id="g_scotland"><h6>Scotland</h6></div>
<div class="gallery_holder">
<ul>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-1.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-2.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-3.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-4.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-5.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-6.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-7.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-8.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-9.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-10.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-11.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-12.jpg" height="150"></li>
<li class="gallery_img"><img src="Assets/Images/Gallery/ScotlandGallery-13.jpg" height="150"></li>
</ul>
</div>
</li>
</ul>
CSS:
.country_holder {
position:relative;
margin-top:2rem;
margin-bottom:2rem;
width:70%;
left:18.5%;
display:block;
overflow-y:scroll;
overflow-x:hidden;
overflow:-moz-scrollbars-horizontal;
border:1px solid black;
}
.gallery_holder{
width:4000px;
height:150px;
position:relative;
background-color:none;
}
li.gallery_img{
padding-right:2px;
float:left;
display:inline-block;
vertical-align:top;
height:150px;
}
這是完美的 - 非常感謝! – Scott
@ Scott很高興幫助你,請閱讀[當有人回答](https://stackoverflow.com/help/someone-answers)知道你應該做什麼,當有人回答你的問題:) –
再次感謝 - 沒有意識到這個! – Scott