[英]How to resize the images to have the same height in group while keeping aspect ratio?
您可以將寬度設置為auto,這將使它們具有相同的高度,並保持縱橫比。 但是,它們的寬度會不同:
.ui.medium.image
{
width: auto;
height: 200px;
font-size: 1rem;
}
最好的方法是使用背景圖像。
例如:
.ui.medium.image {
/*Image should be a div*/
height: 200px;
background-size: contain;
background-position: center;
background-repeat: no-repeat;
}
然后,您可以使用內聯樣式設置圖像:
<div class="image" style="background-image:url('path/to/image.jpg');">
您需要使用CSS背景圖像居中並裁剪圖像。
<style>
.image {
background-position: center;
width: 200px;
height: 200px;
float: left;
}
</style>
<div class="image" style="background-image: url('http://lorempixel.com/400/200/sports/');"></div>
<div class="image" style="background-image: url('http://lorempixel.com/300/500/abstract/');"></div>
<div class="image" style="background-image: url('http://lorempixel.com/200/400/nature/');"></div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.