繁体   English   中英

正文{background-color}在外部CSS中不起作用?

[英]Body {background-color} not working in external css?

我无法使用外部样式表更改背景颜色。 当我尝试使用内部样式表时,它可以完美工作。 这是代码。

ext1.css
<style>
body{
   background-color: red;
}
ul{
   color:green;
}
:link{
    color:aquamarine;
}
p{
   font-family:"arial";
    font-size:20px;
}
</style>


HTML DOC

<!doctype html>
<html>
<head>
<title> Defining external style sheet</title>
<link href="ext1.css" rel="stylesheet" type="text/css">
</head>
<body>
<ul>
<li> <a href="#Home">Home</a></li>
<li> <a href="#News">News</a></li>
<li> <a href="#Contact us">Contact</a></li> 
<li> <a href="#About">About</a></li>
</ul>
<p> NOTE: We use href="#" for test links , in real web sites we will use URL's </p>

您的外部CSS中不能包含HTML <style>标签。

您的CSS文件应如下所示:

body {
   background-color: red;
}
ul {
   color: green;
}
:link {
   color: aquamarine;
}
p {
   font-family: "arial";
   font-size: 20px;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM