(这是我正在选修的一个课程的项目。)这就是我到目前为止所拥有的,但是我不知道如何改变<ul>的背景颜色。我们没有使用单独的CSS,所以这些都会出现在我的HTML文档中。
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
text-align: center;
}
h2 {
text-align: left;
}
h3 {
text-align: left;
}
body {
background-color: pink;
}
* {
font-size: 120%;
font-family: Arial Narrow;
}
</style>
</head>
<body>
<h1>Yada yada!</h1>
<h2>Yada yada:</h2>
<p>Our mission is to yada yada yada yada.</p>
<h3>Why you should get a membership at Yada Yada:</h3>
<ul>
<li>Better yada</li>
<li>Better yada</li>
<li>YADA YADA</li>
</ul>
<p>Yada yada is never out of style!</p>
</body>
</html>发布于 2016-10-27 23:46:15
你的方向是对的。只需像处理body一样为ul创建一个新声明,并指定一个不同于pink的background-color。
发布于 2016-10-27 23:47:07
您可以将background-color直接分配给ul,也可以为其分配几乎任何元素。
ul {
background-color: red;
}发布于 2016-10-27 23:50:09
ul{
background-color: blue;
}这将仅更改UL元素的背景。
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
text-align: center;
}
h2 {
text-align: left;
}
h3 {
text-align: left;
}
body {
background-color: pink;
}
* {
font-size: 120%;
font-family: Arial Narrow;
}
ul{
background-color: blue;
}
</style>
</head>
<body>
<h1>Yada yada!</h1>
<h2>Yada yada:</h2>
<p>Our mission is to yada yada yada yada.</p>
<h3>Why you should get a membership at Yada Yada:</h3>
<ul>
<li>Better yada</li>
<li>Better yada</li>
<li>YADA YADA</li>
</ul>
<p>Yada yada is never out of style!</p>
</body>
</html>
https://stackoverflow.com/questions/40288941
复制相似问题