有没有人知道我的外部样式表在浏览器中没有呈现的内容?
两个文件都在同一个目录中,我尝试了多个浏览器,并且我已经多次清除了所有这些文件的缓存。这可能是小事,因为这是我第一次使用外部样式表,但我完全迷失了,因为一切看起来都是正确的。
heading {
font-family: arial;
color: red;
}
emphasis {
color: blue;
background-color: yellow;
}
<h1 class="heading">Cascading Style Sheets</h1>
<h2>Benefits</h2>
<p>Cascading Style Sheets offer many benefits to web designers. <em class="emphasis">CSS lets you separate style information from HTML</em>, allowing you to provide style sheets for different destination media as your web site requires. You can control the
display characteristics of an entire web site with a single style sheet, making maintenance and enhancements of display information a less taxing chore. You can express a wide range of style properties that increase the legibility, accessibility, and
delivery of your content. You can build page layouts, either flexible, fixed, or responsive to suit your user and content needs. As you will see in this chapter and through the rest of the book, CSS is easy to learn and apply to your web design projects.</p>
答案 0 :(得分:2)
Micheal Platt提供的解决方案:
在外部CSS中,每个类都应以.
因此:
.heading{
font-family: arial;
color: red;
}
.emphasis{
color: blue;
background-color: yellow;
}
是正确的解决方案。
答案 1 :(得分:0)
在css的声明开头错过了点。
.heading {
font-family: arial;
color: red;
}
.emphasis {
color: blue;
background-color: yellow;
}