我一直在努力解決這個問題,我在左邊有一個大圖像,我想在右邊做一個2x2圖像網格(下面有標題),但我似乎無法正確對齊這些圖像。無法制作一個2x2圖像網格[CSS]
試圖在沒有表或Bootstrap的情況下執行此操作。
<div class="content">
<div class="bigpicture">
<!-- -->
</div>
<div class="rightpicture">
<figure class="smallpicture">
<a href="img/img2.jpg" target="_blank"><img src="img/img2.jpg" /></a>
<figcaption class="caption">Text below the image</figcaption>
</figure>
<figure class="smallpicture">
<a href="img/img3.jpg" target="_blank"><img src="img/img3.jpg" /></a>
<figcaption class="caption">Text below the image</figcaption>
</figure>
<figure class="smallpicture">
<a href="img/img4.jpg" target="_blank"><img src="img/img4.jpg" /></a>
<figcaption class="caption">Text below the image</figcaption>
</figure>
<figure class="smallpicture">
<a href="img/img5.jpg" target="_blank"><img src="img/img5.jpg" /></a>
<figcaption class="caption">Text below the image</figcaption>
</figure>
</div>
</div>
的CSS:
.bigpicture { /* picture on the left styling */
border: 1px solid black;
width: 650px;
height: 450px;
margin-left: 50px;
margin-top: 20px;
float: left;
background-image: url("../img/img1.jpg");
background-repeat: no-repeat;
background-size: 100%;
}
.rightpicture {
width: 650px;
height: 450px;
margin-right: 50px;
margin-top: 20px;
float: right;
}
.smallpicture {
vertical-align: top;
display: inline-block;
text-align: center;
}
.smallpicture img {
width: 15%;
height: auto;
padding: 5px; /* space between the image and the border */
margin: 10px; /* space between the 4 images */
border: 1px solid black; /* picture border */
}
.smallpicture a {
text-decoration: none; /* remove the underline under the images */
}
.caption {
display: block;
}
現在它的外觀:
工作。非常感謝! –