当悬停在链接元素上时,我使用 CSS3 制作了发光和填充扩展效果。然而,当动画结束时,您继续将鼠标悬停在它上面时,会出现短暂的卡顿,并且内边距会稍微延伸一些。
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>
最佳答案
发生这种情况是因为 font-weight:bold。字体宽度增加并且没有相应的过渡。
您可以使用 text-shadow 而不是 font-weight 在悬停时突出显示链接:
文字阴影: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;
关于html - 动画结束后短暂的卡顿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29288223/