CSS选择器未选择h1元素

时间:2018-08-02 19:19:05

标签: css css3 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语句都在工作。感谢您的帮助

3 个答案:

答案 0 :(得分:1)

您尝试过

.example {
  width: 100px;
  height: 100px;
  
  background-color: black;
  background-size: cover;
}

答案 1 :(得分:-1)

确保已加载CSS文件。如果已加载,则可以被下面的CSS文件覆盖。 将自定义CSS文件保留在您引用的CSS文件之下。

答案 2 :(得分:-1)

自定义后,您可能会加载一个CSS文件,从而覆盖所需的属性。