我有一个悬停时需要动画的按钮。下图显示了单词“阅读更多”,我希望右侧的黄线扩展到悬停时当前大小的百分之五十左右。
<a href="#" class="read_more">Read More </a> .read_more { font-family: "Gotham SSm A", "Gotham SSm B"; font-size: 20px; color: #002c77; letter-spacing: 0; text-align: center; line-height: 28px; font-weight: bold; text-transform: uppercase; } .read_more::after { content: "\2014"; color: #fcd450; }
答案 0 :(得分:0)
伪代码,因为它看起来好像没有任何东西,但是
.line {
width: 100px;
transition: width .5s ease-in-out;
}
.line:hover {
width: 150px;
}
答案 1 :(得分:0)
请参阅下文。希望这会有所帮助
.read_more {
font-family: "Gotham SSm A", "Gotham SSm B";
font-size: 20px;
color: #002c77;
letter-spacing: 0;
text-align: center;
line-height: 28px;
font-weight: bold;
text-transform: uppercase;
}
div {
position: relative;
display: inline-block;
}
div:after {
content: "";
height: 3px;
width: 20px;
background-color: red;
position: absolute;
right: -20px;
top: 50%;
transform: translateY(-50%);
}
div:hover:after {
width: 30px;
right: -30px;
}
<div><a href="#" class="read_more">Read More</a></div>
答案 2 :(得分:0)
根据您自己的代码,我认为这可以实现您的追求! :)
一旦将其粘贴到您自己的项目中,字体和其他字体将不起作用。
.read_more {
font-family: "Gotham SSm A", "Gotham SSm B";
font-size: 20px;
color: #002c77;
letter-spacing: 0;
text-align: center;
line-height: 28px;
font-weight: bold;
text-transform: uppercase;
}
.read_more:after {
content: '';
position: relative;
display: inline-block;
width: 20px;
height: 2px;
vertical-align: top;
margin-top: 12px;
background-color: #fcd450;
transition: width 0.3s ease;
}
.read_more:hover:after {
width: 30px;
}
<a href="#" class="read_more">Read More </a>