应用CSS到ul类然后li然后a.



我想用CSS改变页脚的颜色。我想改变所有a项目的颜色,因为我给了相同的类,但不知道如何应用CSS。下面是代码:

<div class="col-lg-3 col-md-6 footer-links">
<h4>Our products</h4>
<ul class="footer-items">
<li><a href="#">About trade banner printing</a></li>
<li><a href="#">Delivery options</a></li>
<li><a href="#">Frequently added questions</a></li>
<li><a href="#">What our customer think of us</a></li>
<li><a href="#">Register for trade access</a></li>
<li><a href="#">Contact us</a></li>
</ul>
</div>
<div class="col-lg-3 col-md-6 footer-links">
<h4>Promo and Details</h4>
<ul class="footer-items">
<li><a href="#">About trade banner printing</a></li>
<li><a href="#">Delivery options</a></li>
<li><a href="#">Frequently added questions</a></li>
<li><a href="#">What our customer think of us</a></li>
<li><a href="#">Register for trade access</a></li>
<li><a href="#">Contact us</a></li>
</ul>
</div>
<div class="col-lg-3 col-md-6 footer-links">
<h4>About Our Services</h4>
<ul class="footer-items">
<li><a href="#">About trader banner printing</a></li>
<li><a href="#">Delivery options</a></li>
<li><a href="#">Frequently added questions</a></li>
<li><a href="#">What our customer think of us</a></li>
<li><a href="#">Register for trade access</a></li>
<li><a href="#">Contact us</a></li>
</ul>
</div>
.footer-items > li > a {
/*Your style here*/
}

.,你得到类。使用>,您将获得直接子。

您不需要为每个项目单独编写,所有匹配的项目都将获得样式。

您可以像这样更改链接文本的颜色:

ul.footer-items li a {
color: red;
}

颜色适用于所有具有父<li>,父<ul>footer-items类的<a>标签。

如果你想改变ul中的所有文本颜色,你不必给ul一个class,而是给ul一个css

ul a {
color:green;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
</style>
</head>
<body>
<div class="col-lg-3 col-md-6 footer-links">
<h4>Our products</h4>
<ul>
<li><a href="#">About trade banner printing</a></li>
<li><a href="#">Delivery options</a></li>
<li><a href="#">Frequently added questions</a></li>
<li><a href="#">What our customer think of us</a></li>
<li><a href="#">Register for trade access</a></li>
<li><a href="#">Contact us</a></li>
</ul>
</div>
<div class="col-lg-3 col-md-6 footer-links">
<h4>Promo and Details</h4>
<ul>
<li><a href="#">About trade banner printing</a></li>
<li><a href="#">Delivery options</a></li>
<li><a href="#">Frequently added questions</a></li>
<li><a href="#">What our customer think of us</a></li>
<li><a href="#">Register for trade access</a></li>
<li><a href="#">Contact us</a></li>
</ul>
</div>
<div class="col-lg-3 col-md-6 footer-links">
<h4>About Our Services</h4>
<ul>
<li><a href="#">About trader banner printing</a></li>
<li><a href="#">Delivery options</a></li>
<li><a href="#">Frequently added questions</a></li>
<li><a href="#">What our customer think of us</a></li>
<li><a href="#">Register for trade access</a></li>
<li><a href="#">Contact us</a></li>
</ul>
</div>
</body>
</html>

相关内容

最新更新