当将鼠标悬停在链接元素上时,我发出了一个发光和填充扩展效果。然而,当动画结束,并且你继续在它上面盘旋时,会有一个短暂的口吃,并且填充延伸了一点。
CSS:
#links {
background: rgba(34,34,34,0.75);
max-width: 400px;
padding: 0px 10px 2px 10px;
margin: 0 auto;
position: relative;
right: -100px;
bottom: -100px;
clear: both;
z-index: -1;
}
#links h3 {
padding: 0px;
font-size: 50px;
font-family: 'Raleway', sans-serif;
font-weight: normal;
color: whitesmoke;
}
#links ul {
padding: 0px;
}
#links li {
display:inline;
padding-right: 15px;
}
#links li a:link {
font-family: 'Raleway', sans-serif;
font-weight: normal;
color: whitesmoke;
text-decoration: none;
/*Transitions*/
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
}
#links li a:visited {
font-family: 'Raleway', sans-serif;
font-weight: normal;
color: whitesmoke;
text-decoration: none;
/*Transitions*/
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
}
#links li a:active {
font-family: 'Raleway', sans-serif;
font-weight: bold;
color: AliceBlue;
text-decoration: none;
}
#links li a:hover {
font-family: 'Raleway', sans-serif;
font-weight: bold;
color: AliceBlue;
text-decoration: none;
padding: 6px;
/*Glow*/ -webkit-box-shadow: 0px 0px 20px rgba(255,255,255,0.8);
}
HTML:
<div id="links">
<h3 id="subtitle">Links</h3>
<ul>
<li><a href="">Resume</a></li>
<li><a href="">LinkedIn</a></li>
<li><a href="">GitHub</a></li>
</ul>
</div>
和codepen:http://codepen.io/abs26/pen/RNdbzj
答案 0 :(得分:1)
因为font-weight:bold而发生这种情况。字体的宽度增加,并且没有转换。
您可以使用text-shadow而不是font-weight来悬停它时突出显示链接:
text-shadow:0 0 1px AliceBlue,0 0 1px AliceBlue;
#links li a:hover {
font-family: 'Raleway', sans-serif;
color: AliceBlue;
text-decoration: none;
padding: 6px;
**text-shadow: 0 0 1px AliceBlue, 0 0 1px AliceBlue;**
}
您可以重复文字阴影以巩固您认为合适的“边框”。例如:text-shadow:0 0 1px AliceBlue,0 0 1px AliceBlue,0 0 1px AliceBlue;