【发布时间】:2019-12-31 01:33:10
【问题描述】:
使用来自 W3Schools 的 CSS Image Gallery 代码,我有一种可行的方法来展示由容器组成的图片库。这些容器都有长度不同的文本元素。这导致每一行都有div 等宽但不等高的容器。我想标准化整行的高度。
根据我正在使用的代码,哪些 CSS 更改会产生影响?
<!DOCSTRING html>
<html>
<style>
div.gallery {
border: 1px solid #ccc;
}
div.gallery:hover {
border: 1px solid #777;
}
div.gallery img {
width: 100%;
height: auto;
}
div.desc {
padding: 15px;
text-align: center;
font-size: 12px;
}
* {
box-sizing: border-box;
}
.responsive {
padding: 0 6px;
float: left;
width: 24.99999%;
margin: 6px 0;
}
@media only screen and (max-width: 700px) {
.responsive {
width: 49.99999%;
margin: 6px 0;
}
}
@media only screen and (max-width: 500px) {
.responsive {
width: 100%;
}
}
.clearfix:after {
content: "";
display: table;
clear: both;
}
</style>
<body>
<div class="responsive">
<div class="gallery">
<a href="vid_01.mp4">
<img src="cover_01.png">
</a>
<div class="desc">
<p>Variable text...</p>
</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="vid_02.mp4">
<img src="cover_02.png">
</a>
<div class="desc">
<p>Variable text...</p>
</div>
</div>
</div>
<div class="responsive">
<div class="gallery">
<a href="vid_03.mp4">
<img src="cover_03.png">
</a>
<div class="desc">
<p>Variable text...</p>
</div>
</div>
</div>
</body>
</html>
编辑(2019 年 12 月 30 日 22:48): 这是一个 JSFiddle 演示问题。这是一张图片:
【问题讨论】: