我前几天抓了一个登录页面来处理我正在进行的一个小项目。我几乎没有做任何事情,制作背景和导航栏。当我继续处理它时,我对CSS所做的任何更改都不起作用。例如,我试图将H1的颜色变为白色。我已经尝试清除Mozilla的缓存,万一有些东西被破坏但没有希望。
另外,奇怪的是,我认为我已经获得了整个"用户代理样式表"问题(在chrome上打开时注意到)。有什么建议吗?
继承人HTML:
<!DOCTYPE html>
<html>
<head>
<title> BitStudy </title>
<script src="man.js"></script>
<link rel=styleSheet HREF="home.css" type="text/css" >
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>
<body>
<ul class="topnav">
<li><a class="active" href="#home">BitStudy</a></li>
<li><a href="#news">About</a></li>
<li><a href="#contact">Contact</a></li>
<li class="right"><a href="#about">Log in</a></li>
</ul>
<h1>Testing</h1>
</body>
</html>
&#13;
和css:
body,html{
width:100%;
height: 100%;
margin: 0 auto;
background: url(images/back1.jpeg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
ul.topnav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
font-family: 'Roboto', sans-serif;
font-size:80%;
}
ul.topnav li {float: left;}
ul.topnav li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
ul.topnav li a:hover:not(.active) {background-color: #111;}
ul.topnav li a.active {background-color: #ff751a;}
ul.topnav li.right {float: right;}
@media screen and (max-width: 600px){
ul.topnav li.right,
ul.topnav li {float: none;}
h1{color:white;}
&#13;
答案 0 :(得分:0)
首先:确保index.html和home.css位于同一文件夹中。 然后Mandar Sant说,将HREF改为href。 最后在样式表中添加双字符串引用,如rel =&#34; stylesheet&#34;。所以你有类似
的东西<link rel="stylesheet" href="home.css" type="text/css" >
而不是最初的y代码。
<link rel=styleSheet HREF="home.css" type="text/css" >
答案 1 :(得分:0)
在本地测试并且所有看起来都很好,请确保您对.css文件具有正确的权限,在这种情况下,如果正确包含该文件,请检查开发人员工具(F12)中的NET选项卡。