js+css实现列表滚动头部阴影过渡效果代码

代码语言:html

所属分类:加载滚动

代码描述:js+css实现列表滚动头部阴影过渡效果代码,滚动后头部有阴影过渡效果,滚动顶部又会消失不见。

代码标签: js css 列表 滚动 头部 阴影 过渡

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
<style>
    @import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
* {
  box-sizing: border-box;
}

html {
  font-size: 6.25vmax;
}
@media (max-width: 992px) {
  html {
    font-size: 60px;
  }
}

body {
  min-height: 100vh;
  padding: 0.3rem;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fffbef;
  font-size: 0.26rem;
  font-family: "Poppins", sans-serif;
}

.wrapper {
  width: 6.5rem;
  max-width: 100%;
  padding: 0.3rem 0.5rem;
  color: #fffbef;
  background-color: #8ec0ac;
  border-radius: 0.2rem;
  box-shadow: 0 0 10px #0002;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.title {
  font-weight: bold;
  font-size: 1.5em;
}

.description {
  font-weight: 200;
  font-size: 0.85em;
  line-height: 1.5;
  text-align: center;
}

.list-wrapper {
  width: 100%;
  position: relative;
}
.list-wrapper:before, .list-wrapper:after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 0.5rem;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}
.list-wrapper:before {
  top: 0;
  background-image: linear-gradient(#8ec0ac, transparent);
}
.list-wrapper:after {
  bottom: 0;
  background-image: linear-gradient(360deg, #8ec0ac, transparent);
}
.list-wrapper.top-scroll-hint:before, .list-wrapper.bottom-scroll-hint:after {
  opacity: 1;
}

.list {
  max-height: 4.5rem;
  padding-right: 0.2rem;
  margin-right: -0.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: auto;
}

.event {
  width: 100%;
  padding: 0.2rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border-radius: 0.3rem;
  color: #8ec0ac;
  background-color: #fffbef;
}
.event .event-name {
  font-weight: 500;
}
.event .event-date {
  font-size: 0.8em;
  font-weight: 300;
  opacity: 0.75;
}
</style>

</head>
<body>

<div class="wrapper">
  <div class="title">Upcoming Events 🎉</div>
  <div class="description">Stay tuned for a variety of exciting events! From cultural festivals to educational workshops, there's something for everyone.</div>
  <!-- for adding shadows-->
  <div class="list-wrapper">
    <!-- scrollable area-->
    <div class="list">
      <div class="event">
        <div class="event-name">Event 194</div>
        <div class="event-date">2024/12/31</div>
      </div>
      <div class="event.........完整代码请登录后点击上方下载按钮下载查看

网友评论0