希望有人可以帮助我找出我所缺少的东西。现在,行重叠。我希望根据图像的大小(它们都是相同的大小)适当地间隔开两行。我不知道我错过了什么让它以我想要的方式回应。
img {
max-width: 100%;
-webkit-backface-visibility: hidden;
}
.gallery-project-thumb {
position: relative;
}
.vert-pad {
padding-top: 30px;
padding-bottom: 30px;
}
.gallery-project-thumb img:first-child {
border: 8px solid #fff;
-webkit-box-shadow: 0 0 6px 0.5px rgba(0,0,0,.5);
-moz-box-shadow: 0 0 6px .5px rgba(0,0,0,.5);
box-shadow: 0 0 6px 0.5px rgba(0,0,0,.5);
position: absolute;
z-index: 3;
-webkit-backface-visibility: hidden;
display: block;
}
.gallery-project-thumb img:nth-child(2) {
z-index: 2;
margin-bottom: 15px;
border: 8px solid #fff;
-webkit-box-shadow: 0 0 6px 1px rgba(0,0,0,.5);
-moz-box-shadow: 0 0 6px 1px rgba(0,0,0,.5);
box-shadow: 0 0 6px 1px rgba(0,0,0,.5);
position: absolute;
-ms-transform: rotate(-2deg);
-webkit-transform: rotate(-2deg);
transform: rotate(-2deg);
-webkit-backface-visibility: hidden;
}
.gallery-project-thumb img:nth-child(3) {
z-index: 1;
margin-bottom: 15px;
border: 8px solid #fff;
-webkit-box-shadow: 0 0 6px 1px rgba(0,0,0,.5);
-moz-box-shadow: 0 0 6px 1px rgba(0,0,0,.5);
box-shadow: 0 0 6px 1px rgba(0,0,0,.5);
position: absolute;
-ms-transform: rotate(2deg);
-webkit-transform: rotate(2deg);
transform: rotate(2deg);
-webkit-backface-visibility: hidden;
}

<div class="row vert-pad gallery-project-container" style="margin-left: 75px; margin-right: 20px;">
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="gallery-project-thumb"><img src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="gallery-project-thumb"><img src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="gallery-project-thumb"><img src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="gallery-project-thumb"><img src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"></div>
</div>
</div>
<div class="row vert-pad gallery-project-container" style="margin-left: 75px; margin-right: 20px;">
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="gallery-project-thumb"><img src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="gallery-project-thumb"><img src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="gallery-project-thumb"><img src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"></div>
</div>
<div class="col-sm-6 col-md-4 col-lg-3">
<div class="gallery-project-thumb"><img src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"> <img class="gallery-project-thumb-background" src="https://via.placeholder.com/840x560"></div>
</div>
</div>
&#13;
答案 0 :(得分:1)
由于图像处于绝对位置,因此浏览器不知道制作这些元素的高度。如果您将.gallery-project-thumb类的高度设置为应设置的图像高度
.gallery-project-thumb{
height: 300px;
}