利用css3做一个滚动卡片效果,下面编程教程网小编给大家简单介绍一下实现代码,卡片效果如右图!
html代码如下:
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
<div class="card">
<h2>Card Title</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque at nobis doloremque odit labore provident unde officiis odio sit sint? Vitae accusantium praesentium ullam alias aut quod cum perferendis maiores.</p>
</div>
css3代码如下:
body {
margin-inline:max(0px,((100% - 260px) / 2));
font:90%/1.4 system-ui;
}
.card {
position:sticky;
top:0;
background:white;
padding:1.5rem;
box-shadow:0 -0.5rem 1rem rgba(0,0,0,0.15);
border-radius:4px;
}
.card:nth-child(1) {
top:1rem;
rotate:1deg;
}
.card:nth-child(2) {
top:2rem;
rotate:2deg;
}
.card:nth-child(3) {
top:3rem;
rotate:3deg;
}
.card:nth-child(4) {
top:4rem;
rotate:4deg;
}
.card:nth-child(5) {
top:5rem;
rotate:5deg;
}
.card:nth-child(6) {
top:6rem;
rotate:6deg;
}
.card:nth-child(7) {
top:7rem;
rotate:7deg;
}
.card:nth-child(8) {
top:8rem;
rotate:8deg;
}
.card:nth-child(9) {
top:9rem;
rotate:9deg;
}
.card:nth-child(10) {
top:10rem;
rotate:10deg;
}
.card:nth-child(11) {
top:11rem;
rotate:11deg;
}
.card:nth-child(12) {
top:12rem;
rotate:12deg;
}
.card:nth-child(13) {
top:13rem;
rotate:13deg;
}
.card:nth-child(14) {
top:14rem;
rotate:14deg;
}
.card:nth-child(15) {
top:15rem;
rotate:15deg;
}
以上是编程学习网小编为您介绍的“利用css3做一个滚动卡片效果”的全面内容,想了解更多关于 前端知识 内容,请继续关注编程基础学习网。
沃梦达教程
本文标题为:利用css3做一个滚动卡片效果
基础教程推荐
猜你喜欢
- Vue3.0版本强势升级点特性详解 2024-04-08
- 微信小程序全局配置之tabBar实战案例 2022-10-21
- 2个数组根据相同key合并成新的数组(es5、es6两种 2024-12-10
- JavaScript开发小技巧之各种时间操作 2024-12-08
- web前端性能优化之合理的优化网站图片可以带来更多的流量 2024-03-09
- JS中type=”button”和type=”submit”的区别 2023-12-01
- 第3天:定义语言编码 2022-11-04
- css3+伪元素实现鼠标移入时下划线向两边展开的效果 2023-12-22
- ES5和ES6两种方法合并两个数组并去重 2024-12-10
- javascript判断机器是否联网的2种方法 2024-02-10