悬停时更改按钮和 i class 的颜色
Change color of the button and i class on hover
我有一个 class 包含 span 和 class 图标。悬停时我想同时更改按钮和图标的颜色。如何实现?
这是我的代码示例:
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>
<!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>
你可以通过目标解决这个问题 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>
我有一个 class 包含 span 和 class 图标。悬停时我想同时更改按钮和图标的颜色。如何实现?
这是我的代码示例:
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>
<!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>
你可以通过目标解决这个问题 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>