<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
.box {
height: 200px;
width: 200px;
border: 1px solid #eee;
}
.icon {
position: absolute;
width: 100px;
height: 100px;
left: 50px;
top: 80px;
fill: black;
}
.test-title {
text-align: center;
font-size: 22px;
}
.box:hover {
}
</style>
</head>
<body>
<div class="box">
<p class="test-title">Undo Icon</p>
<svg viewBox="0 0 32 32" preserveAspectRatio="xMidYMin slice" class="icon">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="test.svg#icon-undo"></use>
</svg>
</div>
</body>
</html>
上述代码产生以下输出
但是我希望在鼠标悬停在 .box
类上时获得以下输出
.test-title:hover { colour:red; }
改变字体的颜色,对于svg图像,我可以使用 .icon:hover { fill:red }
来着色,但是我希望在.box
悬停时更改图像和文本的颜色。
fill:red
。 - Harish