python - 为什么我的一些 html 标签在 css 之后,而另一些则没有?

标签 python html css django

<分区>

所以我有一个普通的 html 文件,带有诸如和等标签。

我有这个 CSS 文件:

html, body {
    margin:0; 
    padding:0;
    backgound-color:blue; 
}

a {
    /* Note: For whatever reason this does not apply to templates/tags/naviagtion.html */
    text-decoration: none;
}

无论出于何种原因,当通过以下方式将其应用于我的 html 文件时:

<link rel="stylesheet" type="text/css" href="/static/css/base.css" /> 

注意:放置在基本模板的 base.html 中。 body 的背景和链接的text-decoration 没有更改为css 样式。其他标签如 div 将它们的宽度、 float 等更改为 base.css 文件的样式。当我通过标签中的 style=""亲自编辑标签时,应用了属性。为什么样式是通过 style=""而不是从 css 文件中应用的。我在 base.html 文件中没有覆盖任何内容的内联 css。此外,html 的边距和填充、css 文件中的正文等属性得到应用,而背景颜色则没有。这是怎么回事?

谢谢!

base.html 文件看起来像这样

....
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/base.css" />
</head>
<body>
    <!-- 
    <div class="left_holder" >
    </div>
    -->
    <div class="center_holder" >
        <div id="top_1" >
            <div id="search" class="top_left" >
                <!-- [ searchbar ] -->
                {% include "tags/search.html" %}
            </div>
....

navigation.html 文件:

<div><a href="/" >Home</a></div>

抱歉,不会有 url,因为这是在本地主机上

最佳答案

拼写错误已修复。 css 也区分大小写。

html, body {
    margin:0; 
    padding:0;
    background-color:blue; 
}

a{
    /* Note: For whatever reason this does not apply to templates/tags/naviagtion.html */
    text-decoration: none;
}

你说 text-decoration:none 没有被应用。 您是说您在链接下方看到了下划线,还是在点击后看到了轮廓?

如果你有 text-decoration:none; 你不应该看到下划线;在你的 CSS 中。

如果您看到边框或线条,请尝试添加轮廓:无;以及 {}

的 css

关于python - 为什么我的一些 html 标签在 css 之后,而另一些则没有?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6476330/

上一篇:html - 网页在顶部显示空带

下一篇:javascript - 如何动态设置div大小?

相关文章:

python - 在 Flask-admin ModelView 中对自定义字段进行过滤和排序

来自 Sharepoint 的 HTML 电子邮件看起来与网站上的不同

css - 页脚和内容之间的空间

HTML 表格设计。哪个更好 :A large number of rows in a single table or large number of table with few rows each

javascript - Bootstrap 模态框未正确填充

python - 当尝试使用 Python FTP_TLS 对象下载文件时出现 AttributeError?

python - 如何从 Excel 中访问值,其中第一列是标题

python - 将 Columns 变成多级索引 pandas

javascript - Jquery 在不同位置拖放

javascript - Javascript显示隐藏字段