具体代码我贴在下面,就是在鼠标悬停在按钮上时有动画效果,但文字无法显示,想了好久不知问题出在哪里,
<!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>
迷茫2017-04-11 10:33:45
把代码改成:
a:before{
content: '立即购买';
display: block;
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
text-align: center;
background-color: #f34444;
transform: scale(0,1);
transition: transform .3s ease;
}
a:hover:before{
transform: scale(1,1);
}
看是你想要的效果不