<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="store.css">
<meta charset="UTF-8">
<title>About</title>
</head>
<body>
<ul class="navBar">
<li><a href="http://csc412sfsu.com/~yzhang25/store_home">Home</a></li>
<li><a href="http://csc412sfsu.com/~yzhang25/store_hours">Hours</a></li>
<li><a href="http://csc412sfsu.com/~yzhang25/store_about">About</a></li>
</ul>
<div class="centered-container">
<h1 class="centered-text sansSerif-text">About the store</h1>
<p>Here is the information about the store</p>
<img class="open-sign-img" src="images/testpic.jpg" alt="open sign">
</div>
</body>
</html>
css文件
.orange-text {
color: orange;
}
.blue-text {
color: blue;
}
#red-header {
color: red;
}
.navBar {
list-style-type: none;
margin: 0;
padding: 10px;
background-color: pink;
}
.navBar li {
display: inline;
}
.centered-container {
max-width: 100%;
width: 80%;
height: 90vh;
margin: auto;
background-color: yellow;
}
.centered-text {
text-align: center;
}
.sansSerif-text {
font-family: sans-serif;
}
.centered-container .open-sign-img {
width: 50%;
display: block;
margin: auto;
}
我其余的代码工作正常。在chrome devTool中,它显示CSS类未与我的html文件中的img标签连接。我很困惑,为什么除此以外的其他作品仍然有效。我在goole上搜索了很多,但似乎找不到正确的答案。
答案 0 :(得分:0)
为您的网站提供服务的Web服务器当前发送以下标头以及CSS文件:
HTTP/1.1 200 OK
Date: Fri, 15 Mar 2019 22:56:07 GMT
Server: Apache/2.4.18 (Ubuntu)
Last-Modified: Fri, 15 Mar 2019 22:19:04 GMT
ETag: "22c-584296d30e600-gzip"
Accept-Ranges: bytes
Vary: Accept-Encoding
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: text/css
Transfer-Encoding: chunked
由于Last-Modified
标头,浏览器将缓存此文件,以避免再次从服务器请求它。我觉得这就是您的问题,因为当我现在访问该网站时,该网站的加载情况非常好。
如果您不希望这种情况发生,大多数浏览器的开发人员工具都有一个复选框,可让您在工具打开时禁用缓存。
在Chrome中,可以使用F12打开DevTools,然后单击“网络”标签,然后选中“禁用缓存”来找到该文件。或者,您可以使用 Ctrl Shift R 进行硬重装,这将强制重新请求所有缓存的资产,而不必使用开发工具。
答案 1 :(得分:0)
在您的小提琴中,css是正确的:
具有背景色:
.centered-container .open-sign-img {
background-color: red;
width: 50%;
display: block;
margin: auto;
}
您是否清除了缓存?