当rawValue
超过hover
时,HERE
应居中。第二个问题是image
文本应该消失(重叠),因为只有HERE
应该显示。如何解决这两个问题?
image

.eee span {
font-weight: 700;
font-size:2em;
}
.ggg {
color: yellow;
background: red;
}
.hhh {
text-align: center;
color: #fff;
background-color: black;
}
.hhh:hover {
background-color: green;
background-image: url(http://via.placeholder.com/60x60);
background-repeat: no-repeat;
text-align: center;
}

答案 0 :(得分:1)
使用background-position:center
将图像居中,color: rgba()
隐藏文字
.eee span {
font-weight: 700;
font-size:2em;
}
.ggg {
color: yellow;
background: red;
}
.hhh {
text-align: center;
color: #fff;
background-color: black;
}
.hhh:hover {
background-color: green;
background-image: url(http://via.placeholder.com/60x60);
background-repeat: no-repeat;
background-position:center;
color:rgba(0,0,0,0);
}
<div class="eee"><div class="fff"><span class="ggg">?</span>
<span class="hhh">HERE</span>
</div>
</div>
答案 1 :(得分:0)
试试这个:
.eee span {
font-weight: 700;
font-size:2em;
}
.ggg {
color: yellow;
background: red;
}
.hhh {
text-align: center;
color: #fff;
background-color: black;
}
.hhh:hover {
background-color: green;
background-image: url(http://via.placeholder.com/60x60);
text-align: center;
background-position:center;
color:rgba(0,0,0,0);
}
<div class="eee"><div class="fff"><span class="ggg">?</span>
<span class="hhh">HERE</span>
</div>
</div>