我想在 css 样式表中设置我的背景样式,但想在 html 文件中选择背景图像。虽然整个网站的风格都相同,但每个页面上的图像需要不同。
代码示例:
==== CSS ====
body {
backgound-position: center;
background-repeat: no-repeat;
background-size:1200px 800px;
background-position-x: center;
background-position-y: 50px;
}
==== HTML ====
<html>
<head>
<link href="../css/custom.css" rel="stylesheet">
</head>
<body style="background:url('../img/Car.jpg');">
</body>
</html>
这似乎行不通。 CSS 中的样式被忽略。请注意路径是正确的,因为所有其他元素都有效...
此外,我正在使用 Bootstrap 模板。
请帮忙!
谢谢 D.
最佳答案
您编写 background:url('../img/Car.jpg');
仅使用 background: 将设置每个背景属性。只需将 background:url();
更改为 background-image:url();
:)
关于html - 从样式表和 html 自定义背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36093182/