繁体   English   中英

如何在类中使用CSS属性background拉伸或适合背景图像

[英]how to stretch or fit a background image using css attribute background in a class

如何在类中使用CSS属性background拉伸或适合背景图像。 我在li中使用图标,并希望适合特定的宽度。 但不会渲染。

HMTL代码。

<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>

我正在使用这些课程来适应李的背景

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;
}

暂无
暂无

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

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