gpt4 book ai didi

html - Css 箭头过渡

转载 作者:太空宇宙 更新时间:2023-11-04 13:58:15 25 4
gpt4 key购买 nike

我有一个从右指向左的 css 箭头。我先有箭头,然后是文字。我试图在悬停时实现以下转换:悬停在上方,左侧的箭头消失并出现在文本之后的右侧。如何实现悬停时箭头出现在右侧的效果?

我正在努力实现 this效果却相反

body {
background: black;
}

.the-arrow {
width: 64px;
transition: all 0.2s;
transform: rotate(180deg);
}

.the-arrow.-left {
position: absolute;
top: 60%;
right: 0;
}

.the-arrow.-left .shaft {
width: 0;
background-color: #999;
}

.the-arrow.-left .shaft:before,
.the-arrow.-left .shaft:after {
width: 0;
background-color: #999;
}

.the-arrow.-left .shaft:before {
-webkit-transform: rotate(0);
transform: rotate(0);
}

.the-arrow.-left .shaft:after {
-webkit-transform: rotate(0);
transform: rotate(0);
}

.the-arrow.-right {
top: 3px;
}

.the-arrow.-right .shaft {
width: 64px;
transition-delay: 0.2s;
}

.the-arrow.-right .shaft:before,
.the-arrow.-right>.shaft:after {
width: 8px;
transition-delay: 0.3s;
transition: all 0.5s;
}

.the-arrow.-right .shaft:before {
-webkit-transform: rotate(40deg);
transform: rotate(40deg);
}

.the-arrow.-right .shaft:after {
-webkit-transform: rotate(-40deg);
transform: rotate(-40deg);
}

.the-arrow .shaft {
background-color: #fff;
display: block;
height: 1px;
position: relative;
transition: all 0.2s;
transition-delay: 0;
will-change: transform;
}

.the-arrow .shaft:before,
.the-arrow .shaft:after {
background-color: #fff;
content: '';
display: block;
height: 1px;
position: absolute;
top: 0;
right: 0;
transition: all 0.2s;
transition-delay: 0;
}

.the-arrow .shaft:before {
-webkit-transform-origin: top right;
transform-origin: top right;
}

.the-arrow .shaft:after {
-webkit-transform-origin: bottom right;
transform-origin: bottom right;
}

.animated-arrow {
display: inline-block;
color: #fff;
font-size: 12px;
text-decoration: none;
position: relative;
transition: all 0.2s;
}

.animated-arrow:hover {
color: #eaeaea;
}

.animated-arrow:hover .the-arrow.-left .shaft {
width: 64px;
transition-delay: 0.1s;
background-color: #eaeaea;
}

.animated-arrow:hover .the-arrow.-left .shaft:before,
.animated-arrow:hover .the-arrow.-left .shaft:after {
width: 8px;
transition-delay: 0.1s;
background-color: #eaeaea;
}

.animated-arrow:hover .the-arrow.-left .shaft:before {
-webkit-transform: rotate(40deg);
transform: rotate(40deg);
}

.animated-arrow:hover .the-arrow.-left .shaft:after {
-webkit-transform: rotate(-40deg);
transform: rotate(-40deg);
}

.animated-arrow:hover .main {
-webkit-transform: translateX(80px);
transform: translateX(80px);
}

.animated-arrow:hover .main .the-arrow.-right .shaft {
width: 0;
-webkit-transform: translateX(200%);
transform: translateX(200%);
transition-delay: 0;
}

.animated-arrow:hover .main .the-arrow.-right .shaft:before,
.animated-arrow:hover .main .the-arrow.-right .shaft:after {
width: 0;
transition-delay: 0;
transition: all 0.1s;
}

.animated-arrow:hover .main .the-arrow.-right .shaft:before {
-webkit-transform: rotate(0);
transform: rotate(0);
}

.animated-arrow:hover .main .the-arrow.-right .shaft:after {
-webkit-transform: rotate(0);
transform: rotate(0);
}

.animated-arrow .main {
display: flex;
align-items: center;
transition: all 0.2s;
}

.animated-arrow .main .text {
margin: 0 0 0 16px;
line-height: 1;
font-family: 'Montserrat';
text-transform: uppercase;
}

.animated-arrow .main .the-arrow {
position: relative;
}
<div class="pivot-arrows-1" style="">


<a class="animated-arrow arrow-c-f" href="#">

<span class="main">
<span class="the-arrow -right">
<span class="shaft"></span>
</span>

<span class="text">
Some cool Text
</span>

</span>
<span class="the-arrow -left">
<span class="shaft"></span>
</span>
</a>
</div>

最佳答案

只是为了好玩,用一个伪和过渡来缩短它

body {
background: black;
color:purple;
font-size:2em;
}

a {
color: #fff;
font-size: 12px;
text-decoration: none;
position: relative;/* to be the reference for the absolute pseudo */
display:inline-block;/* to size it and set horizontal margin */
vertical-align:middle;
background:black;
margin:0 68px;
padding:0 0.25em;
}

.animated-arrow::before {
content:'\0003c';/* the sign < to draw edge of the arrow */
font-size:16px;/* might need to be resized */
/*display:inline-block; if not absolute */
width:64px;/* that was your value, equal at the most to the margin of parent link */
background:linear-gradient(to bottom, transparent 50%,currentcolor 50%, currentcolor calc(50% + 1px) , transparent calc(50% + 1px));/* to draw the body arrow */
top:-0.15em;/* if needed */
position:absolute;/* , so coordonate are easier to set */
z-index:-1;/* let slide under the link */
right:100%;
transition: right 0.2s, transform 0.1s 0s;
}
.animated-arrow:hover::before {
right:-64px;
transform:scale(-1,1)
}
a+a {color:gold;}
<a class="animated-arrow arrow-c-f" href="#">Some cool Text</a> ⊛
<a class="animated-arrow arrow-c-f" href="#">Some cool Text of any length</a>

关于html - Css 箭头过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58015552/

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