纯css实现一个带箭头阴影的手风琴动效
效果如图:
可以移入展开。
特征:
1,带有箭头
2,箭头处带有阴影
3,有交互操作
箭头,可以用border来实现:
width: 0;
height: 0;
border: 190px solid transparent;
border-left: 60px solid transparent;
引用可用box-shadow实现,但是如果是贴合非规则图形的阴影,可以用到滤镜:
filter: drop-shadow(5px 0 5px rgba(0, 0, 0, .2));
交互:当前放大,其他兄弟节点渐入透明
.parent{
.child{
opation: 1
}
&:hover{
.child{
opation: .2;
&:hover{
opation: 1
}
}
}
}
代码:vue3
demo.vue
<template>
<div class="step">
<div class="item" v-for="item in list">
<div class="content">
<h2>
<Ellipsis>
{{ item.count }}
<small>项</small>
</Ellipsis>
</h2>
<h3>
<Ellipsis>
{{ item.title }}
</Ellipsis>
</h3>
<Ellipsis class="desc">
{{ item.desc }}
</Ellipsis>
</div>
</div>
</div>
</template>
<script setup>
const list = [
{
count: 13,
title: '测试的标题啊',
desc: '测试的内容测试的内容'
},
{
count: 17,
title: '测试的标题啊',
desc: '测试的内容测试的内容'
},
{
count: 12,
title: '测试的标题啊',
desc: '测试的内容测试的内容'
},
{
count: 38,
title: '测试的标题啊',
desc: '测试的内容测试的内容'
},
]
</script>
<style scoped lang="scss">
.step {
display: flex;
align-items: stretch;
overflow: hidden;
position: relative;
.item {
width: 25%;
display: flex;
align-items: flex-start;
justify-content: center;
flex-direction: column;
position: relative;
height: 375px;
color: #fff;
filter: drop-shadow(5px 0 5px rgba(0, 0, 0, .2));
z-index: 0;
transition-duration: .3s;
cursor: default;
.content {
position: absolute;
left: 0;
top: 0;
z-index: 0;
transition-duration: .3s;
height: 100%;
width: 100%;
display: flex;
align-items: flex-start;
justify-content: center;
flex-direction: column;
padding-left: 20%;
}
&:before {
content: '';
display: block;
position: absolute;
z-index: 0;
width: 0;
height: 0;
right: -249px;
border: 190px solid transparent;
border-left: 60px solid transparent;
pointer-events: none;
}
&:nth-child(1) {
background-color: #7C97CA;
z-index: 3;
&:before {
border-left-color: #7C97CA;
}
}
&:nth-child(2) {
background-color: #5F7CB2;
z-index: 2;
&:before {
border-left-color: #5F7CB2;
}
}
&:nth-child(3) {
background-color: #5771A0;
z-index: 1;
&:before {
border-left-color: #5771A0;
}
}
&:nth-child(4) {
background-color: #294A87;
z-index: 0;
}
h2 {
font-size: 80px;
font-weight: bold;
color: #FFFFFF;
line-height: 117px;
margin: 0;
transition-duration: .3s;
small {
font-size: 28px;
font-weight: 400;
color: #FFFFFF;
line-height: 45px;
transition-duration: .3s;
}
}
h3 {
font-size: 36px;
font-weight: 400;
color: #FFFFFF;
line-height: 56px;
margin: 0;
transition-duration: .3s;
}
.desc {
margin-top: 14px;
font-size: 24px;
font-weight: 300;
color: #FFFFFF;
line-height: 33px;
transition-duration: .3s;
}
}
}
.step {
&:hover {
.item {
.content {
opacity: .1;
}
&:hover {
width: 40%;
.content {
padding-left: 30%;
opacity: 1;
}
h2 {
font-size: 100px;
small {
font-size: 32px;
}
}
h3 {
font-size: 40px;
}
.desc {
font-size: 24px;
}
}
}
}
}
</style>
前端黑科技
前端那些你不知道,又必须掌握的小技巧
推荐阅读
nodejs递归文件夹获取所有文件路径
读取文件夹 {代码...} 判断文件类型 {代码...} 路径拼接 {代码...} 封装 {代码...}
jsoncode阅读 550
还在用 JS 做节流吗?CSS 也可以防止按钮重复点击
举个例子:一个保存按钮,为了避免重复提交或者服务器考虑,往往需要对点击行为做一定的限制,比如只允许每300ms提交一次,这时候我想大部分同学都会到网上直接拷贝一段throttle函数,或者直接引用lodash工具库
XboxYan赞 34阅读 2.4k评论 2
CSS 如何设置自动滚动定位的“安全”间距?
欢迎关注我的公众号:前端侦探介绍两个和滚动定位相关的 CSS 属性:scroll-padding和 scroll-margin在平时开发中,经常会碰到需要快速定位的问题,比如常见的锚点定位 {代码...} 这样,在点击a标签时会自动定位到...
XboxYan赞 31阅读 2.3k评论 2
CSS transition 小技巧!如何保留 hover 的状态?
欢迎关注我的公众号:前端侦探通常情况下,hover 是无法保存状态的。鼠标移入触发额外样式,一旦移出就还原了 {代码...} 这就意味着,如果需要保留hover的状态,可能就不得不借助JS了,比如下面是某某书院的首页...
XboxYan赞 29阅读 3.6k评论 2
现代 CSS 之高阶图片渐隐消失术
在过往,我们想要实现一个图片的渐隐消失。最常见的莫过于整体透明度的变化,像是这样: {代码...} {代码...} 但是,CSS 的功能如此强大的今天。我们可以利用 CSS 实现的渐隐效果已经不再是如此的简单。想想看,...
chokcoco赞 25阅读 2.1k
除了 filter 还有什么置灰网站的方式?
大家都知道,当一些重大事件发生的时候,我们的网站,可能需要置灰,像是这样:当然,通常而言,全站置灰是非常简单的事情,大部分前端同学都知道,仅仅需要使用一行 CSS,就能实现全站置灰的方式。像是这样,我...
chokcoco赞 19阅读 1.7k评论 1
万能的CSS 渐变!单标签绘制一个足球场
一眼望去,这里的形状只有圆形和矩形,在不借助其他标签的情况下(包括伪元素),其实很容易联想到渐变,一起看看如何绘制的吧,有非常多的渐变小技巧~
XboxYan赞 18阅读 1.9k评论 8
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。