img标签类不适用于对应的CSS文件

Saosaosao
<!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上搜索了很多,但似乎找不到正确的答案。

赛诺普

目前,为您的网站提供服务的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,然后点击“网络”标签,然后选中“禁用缓存”来找到该文件。另外,您可以使用CtrlShiftR进行硬重装,这将强制重新请求所有缓存的资产,而不必使用DevTools。

带有“禁用缓存”复选框的Google Chrome DevTools“网络”标签的屏幕快照

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章