如何让 CSS 中的背景拉伸(stretch)或缩放以填充其容器大小?
我是这样做的
body
{
background: url(http://p1.pichost.me/i/40/1639647.jpg) no-repeat fixed;
background-size: 100%;
margin:0;
}
这段代码有什么问题?
最佳答案
试试这个来重置 CSS:
* {
margin:0;
padding:0;
border:0;
}
body {
background: url(http://p1.pichost.me/i/40/1639647.jpg) no-repeat fixed;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
关于css - 如何使用 CSS 缩放和拉伸(stretch)背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38593606/