gpt4 book ai didi

html - 悬停时的小 CSS 动画

转载 作者:搜寻专家 更新时间:2023-10-31 22:59:44 25 4
gpt4 key购买 nike

尝试创建这样的东西。 enter image description here

我不能使用 letter-spacing. 我创建了这段代码,但效果不佳。

http://jsfiddle.net/pyqq8wfe/

.refreshed_logo {
font-family: ProximaNovaBold;
font-size: 50px;
text-decoration: none;
color: #000000;
}
.logo_wrapper {
color: inherit;
text-decoration: none;
width: 250px;
position: absolute;
}
.refreshed_logo:after {
content: 'digital';
width: 20px;
height: 20px;
text-align: center;
position: absolute;
font-size: 20px;
background-color: red;
border-radius: 18px;
color: white;
margin-left: 4px;
margin-top: 3px;
text-indent: 8px;
font-weight: normal;
line-height: 1;
transition-property: width, height;
transition-duration: 0.2s, 0.2s;
transition-delay: 0s, 0.2s;
-o-transition-property: width, height;
-o-transition-duration: 0.2s, 0.2s;
-o-transition-delay: 0s, 0.2s;
-moz-transition-property: width, height;
-moz-transition-duration: 0.2s, 0.2s;
-moz-transition-delay: 0s, 0.2s;
-webkit-transition-property: width, height;
-webkit-transition-duration: 0.2s, 0.2s;
-webkit-transition-delay: 0s, 0.2s;
}
.refreshed_logo:hover:after {
width: 71px;
-webkit-transition: width 0.5s;
transition: width 0.5s;
text-indent: 2px;
}
.logo_wrapper:hover {
text-decoration: none;
}
<a href="/" class="logo_wrapper">
<span class="refreshed_logo">
Granat
</span>
</a>

有什么想法吗?

最佳答案

由于您不能使用 letter-spacing 或拆分单词,下面是使用 border-right 以及 overflow: hidden 的方法设置隐藏“d”之后的所有字符。在悬停时,它们会显示出来,从而产生效果。

.refreshed_logo {
font-family: ProximaNovaBold;
font-size: 50px;
text-decoration: none;
color: #000000;
}
.logo_wrapper {
color: inherit;
text-decoration: none;
width: 250px;
position: absolute;
}
.refreshed_logo:after {
content: 'digital';
width: 20px;
height: 20px;
/*text-align: center; not required */
position: absolute;
font-size: 20px;
background-color: red;
border-radius: 18px;
color: white;
/* following properties were added */
padding-left: 5px;
box-sizing: border-box;
border-right: 5px solid red;
overflow: hidden;
/* end of addition */
font-weight: normal;
line-height: 1;
transition-property: width, height;
transition-duration: 0.2s, 0.2s;
transition-delay: 0s, 0.2s;
}
.refreshed_logo:hover:after {
width: 65px;
transition: width 0.5s;
}
.logo_wrapper:hover {
text-decoration: none;
}
<a href="/" class="logo_wrapper">
<span class="refreshed_logo">
Granat
</span>
</a>

关于html - 悬停时的小 CSS 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33479650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com