我正在尝试对超级链接的字体粗细应用一个过渡,以便在用户悬停时逐渐增加它。
.header a {
color: black;
margin-bottom: -50px;
font-size: 25px;
text-decoration: none;
font-weight: 100;
transition: font-weight 1s ease-in-out;
}
.header a:hover {
font-weight: 900;
}<div class="header">
<a href="#About">Learn More</a>
</div>
当我将鼠标悬停在元素上时,字体粗细在给定的时间(1秒)后发生变化。然而,过渡根本没有任何影响。也就是说,它的字体粗细立即从100变为900,反之亦然。我在这里做错了什么?
发布于 2019-05-19 07:24:40
经过一些尝试之后,这是解决方案:
显然,你必须包含一些字体系列才能进行转换。如下所示:
font-family: "Arial", sans-serif;
.header a {
color: black;
margin-bottom: -50px;
font-size: 25px;
text-decoration: none;
font-family: "Arial", sans-serif;
font-weight: 100;
transition: font-weight 1s ease-in-out;
}
.header a:hover {
font-weight: 900;
}<div class="header">
<a href="#About">Learn More</a>
</div>
附注:我认为这是由于字母和空格等大小的不同,浏览器需要知道特定的字体系列,以便相应地调整字体粗细。
https://stackoverflow.com/questions/56203516
复制相似问题