我正在练习制作自适应网站,我的问题是如何根据网页的分辨率调整图片大小? 这是我的代码:
<html>
<head>
<meta charset="utf-8">
<style>
body {
background: url("streetlight.png");
width: 100%;
height: 100px;
background-attachment: fixed;
position: absolute;
background-repeat: no-repeat;
}
</style>
</head>
<body>
</body>
</html>
答案 0 :(得分:2)
试试这个
body{
background: url(streetlight.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}