在使用CSS过渡时,我看到第二个块(带有类" link1")不起作用,但是第一个块(带有类" link")正在工作。我试图在悬停时放大锚标记内的文本。
我做错了什么?
.link {
width: 100px;
height: 100px;
background: red;
transition: all .5s ease-in-out;
}
.link:hover {
transform: scale(1.2);
}
.link1 {
color: black;
transition: all .5s ease-in-out;
}
.link1:hover {
transform: scale(1.2);
}

<!-- It works.-->
<div class="link"></div>
<br/>
<!-- It does not work-->
<a href=""><span class="link1"><strong>Facebook</strong></span></a>
&#13;
答案 0 :(得分:0)
似乎scale
不适用于内联元素,在此方案中span.link1
。申请
.link1 { display: inline-block; }
<!DOCTYPE html>
<html>
<head>
<style>
.link{
width: 100px;
height: 100px;
background: red;
transition: all .5s ease-in-out;
}
.link:hover {
transform: scale(1.2);
}
.link1{
color:black;
display: inline-block;
transition: all .5s ease-in-out;
}
.link1:hover{
transform: scale(1.2);
}
</style>
</head>
<body>
<!-- It works.-->
<div class="link"></div><br/>
<!-- It does not work-->
<a href=""> <span class="link1"><strong>Facebook</strong></span></a>
</body>
</html>
&#13;