简体   繁体   English

调整CSS图像大小以适合

[英]Resize css image to fit

So im putting list of types and each one has an image. 所以即时输入类型列表,每个都有一个图像。 As you can see the list below has the water image cut. 如您所见,下面的列表中有水图片。 How can I fix this? 我怎样才能解决这个问题?

I have a class for the water text so it can display the text and im trying to add it to a html list. 我有一个关于水文本的类,因此它可以显示文本,并尝试将其添加到html列表中。

this is my class code in css 这是我在css中的类代码

.water{
    background: url('../images/water.png');
    object-fit: contain;
    background-repeat: no-repeat;
    max-width:100%;
    height:auto;
    text-indent: -9999px;
}

在此处输入图片说明

This worked thanks to HolyMoly 这归功于HolyMoly

"object-fit is used directly on img tags to my understanding, I think you want background-size: contain or background-size: cover since you are not applying the css to an image tag, rather using the image as a background" – HolyMoly “据我所知,object-fit直接用于img标签,我想您想要background-size:contains或background-size:Cover,因为您没有将CSS应用于图像标签,而是将图像用作背景” – HolyMoly

kindly check background-size:contain or background: url('../images/water.png') 50px 50px; 请检查background-size:contain或background:url('../ images / water.png')50px 50px; directly mention you size of image 直接提及您的图片大小

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM