CSS 选择器未选择 h1 元素

标签 css css-selectors

我将包含完整的代码,因为我不确定问题出在哪里,但我试图定位的元素是 <h1>PC Lee</h1> ,我正在尝试将字体颜色更改为白色,但它不起作用:

{% extends 'core/base.html' %}
{% load static %}

{% block head %}
<link rel="stylesheet" type="text/css" href="{% static 'core/style/index2.css' %}" />

<!--links specific to style sheet 2 -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet">{% endblock %}

{% block body %}


    <div id="jumbotron">

        <ul>
            <li class="align_left"><a href="#">PCLee</a></li>
            <li class="align_right"><a href="#">Repairs/Upgrades</a></li>
            <li class="align_right"><a href="#">Networking</a></li>
            <li class="align_right"><a href="#">Remote Backups</a></li>
            <li class="align_right"><a href="#">Data Recovery</a></li>

        </ul>

    <div id="h1_div"><h1>PC Lee</h1>
            <img id="image" src="{% static "core/images/logo.png" %}" alt="My image" height="400" width="200"/>
    </div>

    </div>
<h1>dafs</h1>

    <div id="grid">
        <div id="content">
            <h1>About Us</h1>
            <img src="{% static "core/images/first_img.jpeg" %}" alt="My image"/>
            <p>PCLee Computer has been dedicated to providing outstanding technical support to the New York Tri-State area for over 10 years. Specializing in computer sales, repair services, and networking. We have grown our business with individualized attention, honest diagnosis and fast turn-around. PCLee Computer prides itself on customer satisfaction. </p>
            <p>Our technicians can assist your home or office computer repairs, computer setup, software and operating system upgrades, internet connection problems, wireless networking, peripherals (cameras, scanners, printers, iPods,), spyware and virus removal, and all other frustrating computer problems.</p>
        </div>

        <div id="contact_form">
            <h2>Contact Us</h2>
            <form role="form" action="" method="post">
                {% csrf_token %}
                <p>Full Name: <input type="text"></p>
                <p>Email:<input type="text"></p>
                Inquiry:<textarea></textarea>
                <button type="submit">Submit</button>
            </form>
        </div>
    </div>


{% endblock %}

和CSS:

h1{
    font-family: 'Open Sans Condensed', sans-serif;
    color: white !important;
    font-size: 1em;
}

这些 css 语句都不会影响 h1元素,但 css 文件已正确链接,因为所有其他 css 语句都在工作。感谢您的帮助

最佳答案

你试过吗

  #h1_div h1 {
    color: white;
}

关于CSS 选择器未选择 h1 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51660761/

相关文章:

html - border-bottom 长度小于 border-right?

html - 修改父元素样式

css - 无法从 drupal 的侧边栏中删除列表样式类型

jquery - 在访问链接后添加 FontAwesome 图标

css - 使用 :after 将元素定位在其父项下

CSS3 选择器 - 选择第一个元素或之后的元素

javascript - 如何用javascript覆盖CSS?

html - CSS方向和不正确溢出

html - 元素内元素位置的 CSS 选择器

css - 串联类(class)是好的做法吗?