外部 CSS 未在浏览器中呈现
External CSS Not Rendering in Browser
有人知道我的外部样式 sheet 没有在我的浏览器中呈现吗?
两个文件都在同一个目录下,我试过多个浏览器,都清空过多次缓存。它可能有点小,因为这是我第一次使用外部样式 sheet 但我完全迷失了,因为一切似乎都是正确的。
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>
Micheal Platt 提供的解决方案:
在外部 CSS 中,每个 class 前面应该有一个 .
因此:
.heading{
font-family: arial;
color: red;
}
.emphasis{
color: blue;
background-color: yellow;
}
是正确的解。
遗漏了 css 中语句开头的点。
.heading {
font-family: arial;
color: red;
}
.emphasis {
color: blue;
background-color: yellow;
}
有人知道我的外部样式 sheet 没有在我的浏览器中呈现吗?
两个文件都在同一个目录下,我试过多个浏览器,都清空过多次缓存。它可能有点小,因为这是我第一次使用外部样式 sheet 但我完全迷失了,因为一切似乎都是正确的。
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>
Micheal Platt 提供的解决方案:
在外部 CSS 中,每个 class 前面应该有一个 .
因此:
.heading{
font-family: arial;
color: red;
}
.emphasis{
color: blue;
background-color: yellow;
}
是正确的解。
遗漏了 css 中语句开头的点。
.heading {
font-family: arial;
color: red;
}
.emphasis {
color: blue;
background-color: yellow;
}