gpt4 book ai didi

html - 如何在类中使用 css 属性背景拉伸(stretch)或适合背景图像

转载 作者:太空宇宙 更新时间:2023-11-04 13:01:34 29 4
gpt4 key购买 nike

如何在类中使用 css 属性 background 拉伸(stretch)或适应背景图像。我在 li 中使用一个图标并希望适合特定的宽度。但它不渲染。

HTML 代码。

<ul>
<li class="social-bg-facebook">F</li>
<li class="social-bg-twitter">T</li>
<li class="social-bg-user">U</li>
<li>UN</li>
</ul>

我正在使用这些类来适应 li

中的背景

CSS 代码。

.icon-list li {
margin:0px;
padding:0px;
position: relative;
top: -36px;
left: 5px;

}
.icon-list li.social-bg-facebook {
background:url(images/facebook.png) no-repeat;
width:35px;
}
.icon-list li.social-bg-twitter {
background:url(images/twitter-icon.png) no-repeat;
width:35px;
}

最佳答案

您可以使用 background-size :

.icon-list li.social-bg-facebook {
background:url(images/facebook.png) no-repeat;
background-size: 100% 100%;
width:35px;
}

关于html - 如何在类中使用 css 属性背景拉伸(stretch)或适合背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25423650/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com