CSS中,可以使用flex布局將三個(gè)圖片豎排,以下是一個(gè)示例代碼:
HTML代碼:
<div class="image-row"> <img src="image1.jpg" alt="Image 1"> <img src="image2.jpg" alt="Image 2"> <img src="image3.jpg" alt="Image 3"> </div>
CSS代碼:
.image-row { display: flex; flex-direction: column; align-items: center; justify-content: space-between; height: 300px; /* 可以根據(jù)需要調(diào)整圖片的高度 */ } .image-row img { max-width: 100%; height: auto; }
在這個(gè)示例中,我們創(chuàng)建了一個(gè)名為image-row
的div,用于容納三個(gè)圖片,通過設(shè)置display: flex
和flex-direction: column
,我們將圖片豎排。align-items: center
和justify-content: space-between
用于調(diào)整圖片之間的間距和對(duì)齊方式,我們?cè)O(shè)置了一個(gè)高度限制,以確保圖片不會(huì)超出容器的高度,在圖片樣式中,我們?cè)O(shè)置了max-width: 100%
和height: auto
,以確保圖片能夠適應(yīng)容器的大小并自動(dòng)縮放。