我有一个包含span和i class favicon的类。在悬停时我想同时更改按钮和图标的颜色。如何实现?
这是我的代码示例:
CSS
a.btn.btn-seeinfo:hover .fa-chevron-right{
color: #597692;
background-color: transparent;
}
HTML
<a class="btn btn-seeinfo">
<span>"See info"</span>
<i class="fa fa-chevron-right"></i>
</a>
答案 0 :(得分:1)
<!DOCTYPE html>
<html>
<head>
<title>Font Awesome Icons</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<style>
.btn-seeinfo:hover {
color: red;
background-color: transparent;
cursor:pointer;
}
</style>
</head>
<body>
<a class="btn btn-seeinfo">
<span>"See info"</span>
<i class="fa fa-chevron-right"></i>
</a>
</body>
</html>
答案 1 :(得分:0)
您可以通过目标class_name解决此问题 像这样
.btn-seeinfo:hover,
.btn-seeinfo:hover .fa-chevron-right {
color: red;
background-color: transparent;
cursor:pointer;
}
<!DOCTYPE html>
<html>
<head>
<title>Font Awesome Icons</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
</head>
<body>
<a class="btn btn-seeinfo">
<span>"See info"</span>
<i class="fa fa-chevron-right"></i>
</a>
</body>
</html>