CSS 动画线在悬停时增长
CSS Animation Line Grow on Hover
我有一个悬停时需要动画的按钮。下图显示了单词 "Read More" 我希望右侧的黄线在悬停时比当前大小扩大约 %50。
<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: "14"; color: #fcd450; }
伪代码,因为看起来你什么都没有,但是
.line {
width: 100px;
transition: width .5s ease-in-out;
}
.line:hover {
width: 150px;
}
见下文。希望这有帮助
.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>
根据你自己的代码,我认为这实现了你所追求的! :)
将其粘贴到您自己的项目中后,字体和诸如此类的东西就会起作用。
.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>
我有一个悬停时需要动画的按钮。下图显示了单词 "Read More" 我希望右侧的黄线在悬停时比当前大小扩大约 %50。
<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: "14"; color: #fcd450; }
伪代码,因为看起来你什么都没有,但是
.line {
width: 100px;
transition: width .5s ease-in-out;
}
.line:hover {
width: 150px;
}
见下文。希望这有帮助
.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>
根据你自己的代码,我认为这实现了你所追求的! :)
将其粘贴到您自己的项目中后,字体和诸如此类的东西就会起作用。
.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>