我是新來的HTML和CSS,我只是無法弄清楚這一點。我已經設法水平排列三張圖片,因此它們在網頁上彼此舒適地坐在一起。它們的尺寸都根據我的需求而定。但是,我試圖使用Lightbox腳本(允許您在彈出窗口中查看圖像),並且需要將圖像標記封裝在<a>
標記中以鏈接到Lightbox腳本。但是,當我添加<a>
標籤時,圖像變得完全不對齊和不成比例。有什麼建議麼?爲什麼使用錨標籤時圖像變得不對齊?
<div class="imagecont">
<a href="images/gallery/tube1.jpg" data-lightbox="gallery0" data-title="24-Hour Tube concept art.">
<img class="imagecenter" src="images/gallery/tube1.jpg" alt="Tube 1" style="width: 50%; height: 50%;"/>
</a>
<a href="images/gallery/tube2.jpg" data-lightbox="gallery0" data-title="24-Hour Tube concept art.">
<img class="imagecenter" src="images/gallery/tube2.jpg" alt="Tube 2" style="width: 100%; height: 100%;"/>
</a>
<a href="images/gallery/tube3.jpg" data-lightbox="gallery0" data-title="24-Hour Tube concept art.">
<img class="imagecenter" src="images/gallery/tube3.jpg" alt="Tube 3" style="width: 50%; height: 50%;"/>
</a>
</div>
.imagecenter {
justify-content: center;
margin-right: 10px;
margin-left: 10px;
margin-top: auto;
margin-bottom: auto;
vertical-align: middle;
display: inline;
}
.imagecont {
width: 50%;
height: auto;
display: flex;
justify-content: center;
margin-right: auto;
margin-left: auto;
margin-top: 40px;
margin-bottom: 40px;
}