无法在实际样式表中设置html的样式
我正试图利用新的CSS3功能为我的页面创建一个随浏览器窗口缩放的背景 当我把它直接包含在我的html文档中时,它的风格很好用,但这很难看,而且会弄乱我的工作空间,这是我不想做的 我曾试图将它包含在我的样式表中,但它只是没有出现。CSS工作表的其他元素工作正常 谁能告诉我我可能做错了什么 相关HTML无法在实际样式表中设置html的样式,html,css,Html,Css,我正试图利用新的CSS3功能为我的页面创建一个随浏览器窗口缩放的背景 当我把它直接包含在我的html文档中时,它的风格很好用,但这很难看,而且会弄乱我的工作空间,这是我不想做的 我曾试图将它包含在我的样式表中,但它只是没有出现。CSS工作表的其他元素工作正常 谁能告诉我我可能做错了什么 相关HTML <!DOCTYPE html> <html lang="en-US" class="no-js" style="background: url(assets/placehold
<!DOCTYPE html>
<html lang="en-US" class="no-js"
style="background: url(assets/placeholder_one.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover;"
>
<head class>
<!-- To be changed ASAP -->
<title>####</title>
<link rel="icon" href="assets/logo_1.ico">
<meta name="author" content="Noah Litov">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="#####">
<!-- My styles and bootstrap -->
<link href="styles/login.css" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>
像这样写你的css
.no-js {
background: url(assets/placeholder_one.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
width: 100%;
height: 100%;
}
如果您按照以下方式编写css会更好
body{
background: url(assets/placeholder_one.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
width: 100%;
height: 100%;
}
检查资产/placeholder_one.jpg是否可以在指定的路径中访问。login.css位于样式目录中,图像位于资源中。尝试将路径更改为../assets/placeholder_one.jpg。您的代码没有问题,我认为问题在于您的路径。HTML或正文的样式?仍然无法运行。有没有可能是它的记事本++?解决了这个问题。有趣的是,我确信目录会很好,因为资产是一个子文件夹
body{
background: url(assets/placeholder_one.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
width: 100%;
height: 100%;
}