我正在学习CSS,我想在将鼠标悬停在某些文本上时,文本消失并且图像上淡入。我已经测试了一些东西,但它没有按照我想要的方式工作。
文本是 a 中的链接,在悬停时我设置了背景图像。我可以在 the 中使用 an,但我希望文本位于 the 的中间,并且它已经位于具有绝对位置的 a 中。
这是 HTML :
<div class="header">
<!--<ul>-->
<div class="header_element">
<a title="Home" href="page.php"> Home </a>
</div>
Run Code Online (Sandbox Code Playgroud)
还有CSS:
div.header_element {
display: table-cell;
text-align: center;
vertical-align: middle;
height: 100%;
}
div.header_element:hover {
background-position: center;
background-image: url("hover.png");
background-repeat: no-repeat;
}
Run Code Online (Sandbox Code Playgroud)
如果有人能帮助我,我将不胜感激。