以下应用于body标签的样式无效,我正在尝试寻找另一种方法,但无法正常工作。
body {
background: url(/resources/images/pic.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="https://getbootstrap.com/favicon.ico">
<title>Home</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<!-- Custom styles for this template -->
<link rel="stylesheet" href="/css/style.css" >
</head>
答案 0 :(得分:0)
您可以尝试添加:
body, html {
min-height: 100%;
}
我们也没有html
和body
标签的代码。我认为您的系统正在处理它?</ p>
如果不是:您必须更新索引文件:
<html>
<head><!-- copy your head tag --></head>
<body>
</body>
</html>
答案 1 :(得分:0)
您可以调整CSS
身体{
background: url("/resources/images/pic.jpg")
background-position: center;
background-size: cover;
width:100%;
}
如果您根本看不到任何变化,请尝试改变Arts中身体的高度,如上文亚瑟(Arthur)所述。
答案 2 :(得分:0)
您的html中没有body
标签。您正在尝试为不存在的背景应用背景。
答案 3 :(得分:-1)
尝试在url()中添加“”
background-image: url("/resources/images/pic.jpg")
,并为具有背景图像的元素提供宽度和高度
答案 4 :(得分:-1)
您需要在url函数中引用该URL,并且该URL应该是背景图片,而不仅仅是背景。