一、<a>下划线动画
a {
text-decoration: none;
position: relative;
display: inline-block;
}
a::after {
content: "";
position: absolute;
left: 100px;
bottom: 30px;
width: 0;
height: 3px;
background-color: #eed03b;
transition: width 0.3s ease;
}
a:hover::after {
animation: underline-animation 0.5s forwards;
}
@keyframes underline-animation {
0% {
left: 0;
width: 0;
}
100% {
left: 0;
width: 100%;
}
}
二、图片上滑动画
.r_image {
max-width: calc(33.33% - 10px);
margin-right: 10px;
transition: transform .2s;
opacity: 0;
animation-name: fadeUp;
animation-duration: 1s;
animation-fill-mode: forwards;
}
.r_image:hover {
transform: scale(1.1);
}
.r_image:nth-child(1) {
animation-delay: 1s;
}
.r_image:nth-child(2) {
animation-delay: 2s;
}
.r_image:nth-child(3) {
animation-delay: 3s;
}
@keyframes fadeUp {
0% {
transform: translateY(20px);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}
常用样式
overflow: hidden;
object-fit: cover;
background-color: transparent;
cursor: pointer;
opacity: 0.5;
transition: opacity 0.3s ease;
transition: all 0.7s ease;
position: fixed;固定元素在原位置,一般用于首页导航固定,再配合z-index: 1; 确保它显示在 carousel 之上 ,可配合top和right调依据窗口的位置,不依赖任何元素
border-radius: 50%;
filter: blur(10px);
width: 100vw;
height: 100vh;
background-size: cover;
background-repeat: no-repeat; 图像不会重复
background-size: cover; 设置背景图像的大小。cover 值意味着背景图像将被缩放以完全覆盖元素的整个内容区域
background-position: center center;这个属性用于设置背景图像的初始位置。center 值意味着图像将被放置在元素的水平和垂直中心
background-attachment: fixed;
box-shadow: 0 0 20px rgba(0, 0, 0, 10);
background: linear-gradient(to bottom, rgba(0, 0, 0, 10), rgba(0, 0, 0, 0));
text-decoration: none;
font-weight: bold;
filter: brightness(80%);
==============================
关于位置:
居中的几种方式:
块级元素居中 margin: 0 auto;和display: flex; align-items: center; justify-content: center;
文本水平居中text-align: center;
右移50%再以元素中心点左移元素的50%:(注意块级元素,比如div)
margin-left: 50%;
transform: translateX(-50%);
======================================================
<div style={{ position: "relative",width: "100%",height: "100%"}}>
<img src={d.url}/>
<div style={{position:"absolute",top:"50%",left:"40%"}}>学生活动</div>
</div>
=======================================================
.big-image-image-container .slick-slide img {
transform: scale(1.1);
transition: transform 2s ease-in-out;
}
.big-image-image-container .slick-active img {
transform: scale(1);
}
======================================================
.big-image-image-container.hover {
transform: scale(1.1);
transition: transform 2s ease-in-out;
}
=====================================================
滚动条
::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-track {
background: #646464;
}
::-webkit-scrollbar-thumb {
background: #1c00ff;
}
==========================
伪元素
.menu1::after {
content: '';
position: absolute;
top: 70%;
left: 0;
width: 0;
height: 5px;
background-color: #ff9d00;
transition: all 0.7s ease;
}
.menu1:hover::after {
width: 100%;
}