我正在使用 bootstrap,并试图使我的背景图像具有响应能力,但它不起作用!这是我的代码...
html
<div class="row">
<div class="bg">
<img src="../img/home_bg.jpg" alt="home background image">
</div><!-- /.bg -->
</div><!-- /.row -->
css
.bg {
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
请帮我!谢谢你!
您需要更多地了解背景图像和内嵌图像之间的区别。您不能将 img 标签设置为背景,它是块级元素,并与文档一起流动。背景图像是元素的属性。由于您希望此图像作为整个页面的背景,因此可以将背景图像应用到 html 或 body 元素。
http://jsfiddle.net/8L9Ty/3/ http://jsfiddle.net/8L9Ty/3/
body {
background: url('http://placekitten.com/900/900');
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)