具体代码我贴在下面,就是在鼠标悬停在按钮上时有动画效果,但文字无法显示,想了好久不知问题出在哪里,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>css3动画</title>
<style type="text/css">
.btn-box{
margin: 50px auto;
width: 200px;
}
a{
text-decoration: none;
position: relative;
display: inline-block;
background-color: #f01414;
color: #fff;
height: 60px;
line-height: 60px;
padding: 0 35px;
border-radius: 3px;
font-size: 18px;
font-weight: 700;
transition: background-color .3s ease;
}
a:hover{
background-color: #f34444;
}
a:before{
content: '';
display: block;
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
background-color: #f34444;
visibility: hidden;
z-index: 1;
transform: scale(0,1);
transition: transform .3s ease;
}
a:hover:before{
visibility: visible;
transform: scale(1,1);
}
</style>
</head>
<body>
<p class="btn-box">
<a href="#" class="btn">立即购买</a>
</p>
</body>
</html>
很明显a的伪类遮住了 a上文字(你给before的opacity改成0.5就看见了),可以给content“立即购买”,人后调整文字居中就行了
把代码改成:
看是你想要的效果不