這似乎是一個常見問題,但我遇到了麻煩。 當我設置我的CSS與將圖像對齊到頁面的底部
position: absolute;
bottom: 0;
,所有我的圖片結束相互重疊,而不是彼此相鄰被顯示,在底部。 我該如何解決這個問題?
編輯:代碼:: http://jsfiddle.net/5MXLb/
:因爲點擊時,目標圖像是應該去的網頁:target{
position:absolute;
top:0
}
編輯的頂部,我不能在自己的div包住它們
div#main{
text-align: center;
}
.gallery{
display: inline-block;
height: 100%;
}
.gallery img{
display: inline-block;
max-height: 10%;
bottom: 0;
position: absolute;
}
.gallery img:target{
position: relative;
top: 0;
max-height: 90%;
}
HTML:
<div id="main">
<div class="gallery">
<a href="#img1"><img id="img1" src="http://placehold.it/200" /></a>
<a href="#img2"><img id="img2" src="http://placehold.it/400" /></a>
<a href="#img3"><img id="img3" src="http://placehold.it/600" /></a>
<a href="#img4"><img id="img4" src="http://placehold.it/800" /></a>
<a href="#img5"><img id="img5" src="http://placehold.it/1000" /></a>
</div>
</div>
你能顯示代碼嗎?如果圖像數量有限且寬度已知,則可以考慮設置左側。或者將圖片保存在div中併爲div設置位置。 – Karthikeyan
嘗試「顯示:內嵌塊」。 –
更新了代碼,我確實已經內嵌塊 –