html - CSS 文件在特定文件夹中时未加载

标签 html css

我有以下代码:

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Accueil</title>

    <link rel="stylesheet" href="css/header-search.css" />
    <link rel="stylesheet" href="css/header.css" />

</head>

<body>

    <header class="header-two-bars">

        <div class="header-first-bar">
            <div class="header-limiter">
                <h1><a href="#">Jeannot<span>Boutique</span></a></h1>

                <div class="member-area-buttons">
                    <a href="form-register.html" class="signup-button">Sign Up</a>
                    <a href="form-login.html" class="login-user">Log In</a>
                </div>


                <div class="container-1">
                    <span class="icon"><i class="fa fa-search"></i></span>
                    <input type="search" id="search" placeholder="Search..." />
                </div>
            </div>

            <div class="clear"></div>
        </div>

        <div class="header-second-bar">
            <div class="header-limiter">
                <nav>
                    <a href="#"><i class="fa fa-male"></i> Accueil</a>
                    <a href="#" class="selected"><i class="fa fa-female"></i> Chaussures</a>
                    <a href="#"><i class="fa fa-folder-o"></i> Vêtements</a>
                    <a href="#"><i class="fa fa-pencil"></i> Accessoires</a>
                    <a href="#"><i class="fa fa-check"></i> Sur mesure</a>
                    <a href="#" style="color: pink;"><i class="fa fa-pencil"></i> Blog</a>
                    <a href="#" style="color: pink;"><i class="fa fa-check"></i> Promo</a>
                </nav>
                <div class="nav-social-media">
                    <a href="#" style="background-color:#3b5998;"><i class="fa fa-facebook"></i></a>
                    <a href="#" style="background-color:#55acee;"><i class="fa fa-twitter"></i></a>
                    <a href="#" style="background-color:#dd4b39;"><i class="fa fa-google-plus"></i></a>
                    <a href="#" style="background-color:#125688;"><i class="fa fa-instagram"></i></a>
                </div>
                <div class="clear"></div>
            </div>
        </div>

    </header>
</body>

基本上,我有一个文件夹,其中包含我的 css 文件。当我从 css 文件夹加载文件 header.css 时,它没有任何效果,但是一旦与 index.html 位于同一位置,一切就完美了.

我一直在努力寻找答案,但没有办法。 我的文件系统结构如下:

File System Structure

请帮我找出我的代码有什么问题。

PS:我用过W3 Validator,一切正常。

最佳答案

https://stackoverflow.com/a/9480801

Add

type="text/css"

to your link tag

While this may no longer be necessary in modern browsers the HTML4 specification declared this a required attribute.

你可以试试这个:

specify href="./style.css" which the . specifies the current directory

关于html - CSS 文件在特定文件夹中时未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36661958/

相关文章:

javascript setAttribute 样式

c# - 如何更改 asp.net 复选框/单选按钮 css 并正确运行 atserver

python - 使用Python从html中提取列(Beautifulsoup)

javascript - 通过 JavaScript 操作剪贴板

javascript - 子页面处于事件状态时保持 Accordion 菜单打开

html - 防止列表项填充在水平列表中换行

javascript - 为 mvc 突出显示选定的 div ng-repeat

html - z-index 和 CSS 旋转

javascript - 如何解决操作 iframe 的 js 和 iframe 加载之间的竞争条件?

javascript - Css3动态添加的元素没有得到动画