我正在创建一个网站,我的身体上有一个背景图像属性。我希望背景图像具有指定的宽度(以像素为单位),但我无法找到任何有效的内容。
这是我到目前为止所做的:
body {
background-image: url("http://kids.nationalgeographic.com/content/dam/kids/photos/animals/Birds/H-P/mallard-male-standing.jpg.adapt.945.1.jpg");
background-size: cover;
}

<!DOCType html>
<html>
<body>
</body>
</html>
&#13;
答案 0 :(得分:1)
body {
background-image: url("https://images.unsplash.com/photo-1477915737647-b5246ee6de6f?dpr=1&auto=format&fit=crop&w=1500&h=1000&q=80&cs=tinysrgb&crop=");
background-size: 500px auto;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
&#13;
<!DOCType html>
<html>
<body>
</body>
</html>
&#13;
答案 1 :(得分:0)
.your-div {
display: inline-block;
width: 100px;
}