[英]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.