我的 CSS 文件在我的 PHP 文件中不起作用

新手上路,请多包涵

我不明白为什么每当我对它进行一些更改时我的 css 文件都不起作用。我之前输入的代码工作正常,但每当我更改代码时,它都不会显示。

     <?php
session_start();
 ?>

<?php

  include "dbt_connect.php";

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Movies&amp;Stuff</title>
    <script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
  crossorigin="anonymous"></script>
  <link rel="stylesheet" href="FontAwesome/css/fontawesome-all.min.css">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="index.css">

  <style>
    #footer{
        width: 100%;
        height: 100px;
        margin-bottom: 0px;
        background-color: gray;
        text-align: center;
        color: white;
    }
    #footer pre{
        padding-top: 50px;
        font-size: 16px;
    }
    #footer a{
        color: white;
        text-decoration: none;
    }
  </style>

  <script type='text/javascript' src='//platform-api.sharethis.com/js/sharethis.js#property=5b0ae82b461c9500119099e0&product=sticky-share-buttons' async='async'></script>
</head>
<body>
    <header id="top_header" style="margin-top: 20px">
        <div class="clear">
        <h1 id="logo">Movies<span id="and">&amp;</span>Stuff</h1>
        <nav id="main_nav">
            <?php
                if (isset($_SESSION['user_id'])) {
                    echo '
                    <a href="#" class="menu"><i class="fa fa-bars"></i></a>
                    <a href="Movies.php">Movies</a>
            <a href="TV Series.php">TV Series</a>
            <a href="AboutUs.php">About Us</a>
            <a href="ContactUs.php">Contact Us</a>

                    <form action="Includes/logout.inc.php" method="POST" style="float:right; margin-right:1em; border:none;">
                    <button type="submit" name="submit" style="background-color:black; border:none; color: #A5A5A5FF; font-size:17px;outline-style:none;">Logout</button>
                    </form>';
                }else{
                    echo '
                    <a href="#" class="menu"><i class="fa fa-bars"></i></a>
                    <a href="Movies.php">Movies</a>
            <a href="TV Series.php">TV Series</a>
            <a href="AboutUs.php">About Us</a>
            <a href="ContactUs.php">Contact Us</a>
            <span class="login" style="margin-right: -1em;"><a href="login.php">Login</a></span> | <span class="signup"><a href="signup.php">Signup</a></span>';
                }

             ?>

        </nav></div>

这是我的 php 文件代码,我使用 awesome 字体在菜单中添加了一个栏,并使其在我的 css 外部文件中不显示任何内容,但它只是显示出来了。我不明白为什么我的 css 文件不能处理我的任何其他 php 文件。我在本地主机上运行它。我尝试重新启动它,但没有找到任何结果。

     *{
    margin:0 auto;
}
body{
    font-family: sans-serif;
    background-color: black;
    color:#A8A8A8FF;
}
h1 h2 h3 h4 h5 h6{
    font-weight: 500;
}
.clear{
    clear: both;
}
#top_header{
    height: 150px;
}

.menu{
    display: none;
}
#logo{
    float:left;
    padding: 20px;
    text-transform: uppercase;
    color: white;
}
#and{
    font-weight: normal;
}
#main_nav{
    float: right;
    padding: 30px;

#main_nav a{
    color: #A5A5A5FF;
    margin-right: 1em;
    text-decoration: none;
}
.search{
    display: inline-flex;
    font-size: 20px;
    width: 97%;

}
.searchterm{
    width: 97%;
    font-size: inherit;
    border: 0.1em solid #6D6D6DFF;
    border-radius: 0.5em 0 0 0.5em;
    padding:0.2em 0.5em;
    margin-left: 20px;
    outline-style: none;
    transition: 1s all;
}
.search-btn{
    font-size: inherit;
    border: 0.1em solid #6D6D6DFF;
    border-radius: 0 0.5em 0.5em 0;
    cursor: pointer;
    outline-style: none;
    width: 100px;

}
.search-btn i{
    color: #6B6B6BFF;
}
.searchterm:focus{
    border:0.1em solid #C6C6C6FF;
}

这是我的外部 css 代码,我在顶部标题下的类菜单中添加了 display:none 但我仍然一无所获。上次我在制作页脚时出现了这个问题,但它没有用,所以我在内部 css 中做了。请帮我解决这个问题。

原文由 yoshik karnawat 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 449
1 个回答

缓存问题。

尝试改变

<link rel="stylesheet" href="index.css">

<link rel="stylesheet" href="index.css?v=<?php echo time(); ?>">

这将强制 CSS 重新加载。

原文由 Dampen59 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题