gpt4 book ai didi

css - 悬停时的对 Angular 线动画

转载 作者:行者123 更新时间:2023-11-28 16:02:50 25 4
gpt4 key购买 nike

我正在尝试从这个网站复制这个对 Angular 箭头动画:https://robertsspaceindustries.com/

https://imgur.com/a/6V9T2T7

这是一个小样板:https://jsfiddle.net/randal923/x0ywchq5/8/

我不确定放置箭头的最佳方式是什么以及如何设置它的动画。提前致谢。

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.8.1/css/all.css"
integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
type="text/css"
media="screen"
href="./css/style.css"
/>
</head>
<body>
<div class="grid">
<div class="grid__project">
<img
src="https://tympanus.net/Development/HoverEffectIdeas/img/17.jpg"
alt="img17"
class="grid__project-image"
/>
<div class="grid__project-icons">
<i class="fas fa-chevron-up grid__project-icons--1"></i>
<i class="fas fa-chevron-up grid__project-icons--2"></i>
</div>
<div class="grid__project-icons">
<i class="fas fa-chevron-up grid__project-icons--3"></i>
<i class="fas fa-chevron-up grid__project-icons--4"></i>
</div>
</div>
</div>
</body>
</html>


.grid {
display: flex;
flex-wrap: wrap;

&__project {
position: relative;
margin: 1rem;

&-image {
height: 20rem;
border-radius: 0.3rem;
box-shadow: 0 5px 2rem rgba(0, 0, 0, 0.3);
}

&-icons {
display: flex;
position: absolute;
height: 100%;
width: 100%;
top: 0;
font-size: 1.5rem;

&--1 {
}

&--2 {
margin-left: 90%;
}
&--3 {
margin-top: 70%;
}
&--4 {
margin-left: 90%;
margin-top: 70%;
}
}
}
}

最佳答案

这是一个使用多重背景创建箭头的想法,然后为位置的原点设置动画以创建所需的效果:

.box {
width:200px;
height:200px;
padding:20px;
box-sizing:border-box;
background:
linear-gradient(#000,#000) top left,
linear-gradient(#000,#000) top left,
linear-gradient(#000,#000) bottom left,
linear-gradient(#000,#000) bottom left,
linear-gradient(#000,#000) bottom right,
linear-gradient(#000,#000) bottom right,
linear-gradient(#000,#000) top right,
linear-gradient(#000,#000) top right,
red;
background-size:20px 2px,2px 20px;
background-origin:content-box;
background-repeat:no-repeat;
transition:0.3s all;
}
.box:hover {
padding:5px;
}
<div class="box">

</div>

以图片为背景:

.box {
width:200px;
height:200px;
position:relative;
background: url(https://picsum.photos/800/600?image=1069) center/cover;
}

.box:before {
content:"";
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
padding:20px;
background:
linear-gradient(#000,#000) top left,
linear-gradient(#000,#000) top left,
linear-gradient(#000,#000) bottom left,
linear-gradient(#000,#000) bottom left,
linear-gradient(#000,#000) bottom right,
linear-gradient(#000,#000) bottom right,
linear-gradient(#000,#000) top right,
linear-gradient(#000,#000) top right;
background-size:20px 2px,2px 20px;
background-origin:content-box;
background-repeat:no-repeat;
transition:0.3s all;
}
.box:hover:before {
padding:5px;
}
<div class="box">

</div>

关于css - 悬停时的对 Angular 线动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55646770/

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