html 不会链接到本地​​系统上的外部样式表

标签 html css google-chrome

示例 html(实际上是 aws 服务器上 django 的模板)在下面,然后是 css。我有一个 github 存储库,我用它来将文件从我的本地机器来回传送到 aws 机器,所以这是在本地发生的。我最初尝试使用 ../css/limbo.css 中的 css 文件(相对于 html),但随后将 css 移动到与 html 相同的文件夹以查看我是否遇到目录路径问题。 a href 是指向它的原始位置的链接,顺便说一句,确实有效。

名称.html:

<!DOCTYPE html>
<html>
<head>
<style>
    <link rel="stylesheet" type="text/css" href="limbo.css">

</style>
</head>
<body>

<div class=top> <h1>This is a heading</h1> </div>
<div class=left> <h3>Left Side</h3> </div>

<div class=main> 
    <p>This is a paragraph.</p><br>
    <a href="../css/Limbo.css">css</a>
    <form action="/polls/name-test.html" method="post">
        {% csrf_token %}
        {{ form }}
        <input type="submit" value="OK">
    </form>
    <br><p class=red>This is a second paragraph</p>
</div>
</body>
</html>

limbo.css:

/*
Theme Name: Limbo browser
Theme URI:
Description:
    for CS419 - Oregon State University
    Fall 2016

Version: 1.0
Author: Keith McKinley, John Watts, Marta Wegner
Author URI:
*/

/* reset styles */
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var, b, u, i, center,
dl, dt, dd, ol, ul, li, fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
    margin: 0; padding: 0;  border: 0; outline: 0; font-size: 100%;
    vertical-align: baseline; background: transparent;
}
body { line-height: 1; }
ol, ul { list-style: none; }
blockquote, q { quotes: none; }
blockquote:before, blockquote:after, q:before, q:after { content: ''; }
:focus { outline: 0; }
ins { text-decoration: none; }
del { text-decoration: line-through; }
table { border-collapse: collapse; border-spacing: 0; }

form {color: yellow;}

body {
    font-size: 62.5%;
    text-align: center;
    color: #000000;
}
.bold {
    font-weight: strong;
}

/* container - place inside each section or around the entire page depending on your layout */
.container {
    width: 960px;
    margin: 0 auto;
    text-align: left;
    position: relative;
}

/* for clearing any floats <br class=&quot;clearfloat&quot; /> */
.clearfloat {
    clear:both;
    height:0;
    font-size: 1px;
    line-height: 0px;
}

.top {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  width: 100%;
  height: 23px;
}
.main {
    padding-top: 23px;
}
.left {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  width: 10%;
  height: 100%;
  border: right;
  padding-top: 10em;
}

一开始以为是django的问题,但是我本地连django都没有(win8.1 surface, fwiw),所以这只是一个chrome 53.0.2785.143浏览器。

最有趣的是,如果我复制 limbo.css 的全部内容并将其放入 html header 的样式 block 中,它会按预期工作。我只是在做一些愚蠢的事情来确保一切都按预期工作,然后再构建网站。

https://jsfiddle.net/bwrkcey6/可能会奏效,也许会有帮助。

最佳答案

您的 link 标签不应位于 style 标签内。

更正了 HTML,删除了样式标签:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="limbo.css">
</head>
<body>

<div class=top> <h1>This is a heading</h1> </div>
<div class=left> <h3>Left Side</h3> </div>

<div class=main> 
    <p>This is a paragraph.</p><br>
    <a href="../css/Limbo.css">css</a>
    <form action="/polls/name-test.html" method="post">
        {% csrf_token %}
        {{ form }}
        <input type="submit" value="OK">
    </form>
    <br><p class=red>This is a second paragraph</p>
</div>
</body>
</html>

关于html 不会链接到本地​​系统上的外部样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39939401/

相关文章:

javascript - JQuery Mobile - 附加新的动态内容 - 未应用 CSS

css - 如何使 Bootstrap 表单居中

javascript - 脚本执行暂停时如何在chrome devtools中运行异步代码?

javascript - Chrome 扩展程序在所有选项卡中设置切换开关状态

javascript - jQuery - 缩放字体大小以填充父 div 高度

html - 在 block 级元素中声明位置固定或绝对

javascript - HTML5 音频播放器 - 自动播放下一类实例

css - 在页面搜索中隐藏文本

c# - Chrome 是如何实现其标签的?

css - DIV 不遵守 CSS 规则