简体   繁体   English

如何使背景与css中的div大小相同

[英]how to make the background the same as the div size in css

I'm developing a website and I need to know how can I make the background the same size of the div in the css .. I'm trying to make the BG size auto but it doesn't works > So does any one know a solution for that !! 我正在开发一个网站,我需要知道如何使背景与css中的div大小相同..我正在尝试使BG尺寸自动但它不起作用>所以任何人都知道解决方案!!

Thanks 谢谢

Try: 尝试:

{  
 background: url(bgimage.jpg) no-repeat;
 background-size: 100%;
}
#header { 
      background: url(images/bg.jpg) no-repeat center center fixed; 
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
      background-size: cover;
    }

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

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