0
我一直在試圖做一個簡單的圖庫,其中圖片漂浮在一行中,但在中心..對不起,我的英語不好。製作一個漂浮在中心的圖片庫
但是我遵循w3s的例子,並嘗試使用我的標誌,但它從左到右浮動,我希望它儘可能居中,但連續有超過1張圖片。
這裏是我的CSS
div.img {
margin: 5px;
border: 1px solid #d60079;
float: left;
width: 180px;
}
div.img:hover {
border: 2px solid #f0068a;
}
div.img img {
width: 100%;
height: auto;
float:center;
}
div.desc {
padding: 15px;
text-align: center;
}
和HTML
<div class="img">
<a target="_blank" href="testlogo.png">
<img src="test4.png" alt="Fjords" width="300" height="200">
</a>
<div class="desc">Add a description of the image here</div>
</div>
<div class="img">
<a target="_blank" href="testlogo.png">
<img src="test4.png" alt="Fjords" width="300" height="200">
</a>
<div class="desc">Add a description of the image here</div>
</div>
</div>
</body>
圖片仍然漂浮在左側。 – Whitecobra
你是什麼意思圖片?你的意思是父母的div嗎?包含圖片和說明? –
我有2張照片,例如,如果你正在使用word,你可以選擇從左側,中間或右側寫入,目前,我的照片是從左側開始的,我希望他們從中心開始 – Whitecobra