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