css实现好看的card展示效果

3 篇文章 0 订阅

实现效果:鼠标移入移出后,给card添加对应的样式,视觉上增加动态效果
主要使用到 transitionbox-shadow 这两个属性。页面实现上部分代码使用到了antDesign组件。

最下方赋完整代码

首先,先在界面中创建几个div框,前台界面我在js文件中创建的vue组件
在这里插入图片描述

<div class="yjxxbox">
     <div class="jyxxline">
         <div class="jyxxtitle">标题信息</div>
         <div class="jyxxchildren">子项目内容</div>
         <div class="jyxxchildren">子项目内容</div>
         <div class="jyxxchildren">子项目内容</div>
         <div class="jyxxchildren">子项目内容</div>
     </div>
     <div class="jyxxline"></div>
 </div>

然后css中给每个div框设置样式

.yjxxbox{
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: auto;
}
/* 每一个项目的窗口 */
.jyxxline{
    display: flex;
    align-items: center;
    height: 300px;
    width: 100%;
    margin: 10px;
    padding: 5px 6px;
}
/* 每个项目的标题信息 */
.jyxxtitle{
    height: 300px;
    width: 300px;
    background-color: #fff;
    border-radius: 2px;
    border: 1px solid #d9ecff;
    transition: all .2s cubic-bezier(.645,.045,.355,1);
}
/* 每个子项目的项目窗体 */
.jyxxchildren{
    border-radius: 2px;
    height: 300px;
    width: 400px;
    margin: 0 10px;
    background-color: #fff;
    border: 1px solid #d9ecff;
    transition: all .2s cubic-bezier(.645,.045,.355,1);
}
.jyxxtitle:hover,.jyxxchildren:hover{
    cursor: pointer;
    box-shadow: 0 6px 16px -8px #00000014, 0 9px 28px #0000000d, 0 12px 48px 16px #00000008;
}

前台展示效果为(鼠标移入后):
在这里插入图片描述

再根据项目的实际情况,填充card。
根据实际需求,大致的实现效果如下:

在这里插入图片描述

在这里插入图片描述
完整代码(数组这里我随便设置了两个值):
js部分:

  Vue.component("s-table-newsjyxx",{
    template:`<div :style="{width:'100%',height:'100%'}">
        <div class="yjxxbox">
            <div class="jyxxline" v-for="(item,index) in jyxxList">
                <div class="jyxxtitle">
                    <div class="jyxxtitle-xmmc">{{item.name}}</div>
                    <div class="jyxxtitle-xmbh">({{item.xmbh}})</div>
                </div>
                <div class="jyxxchildren">
                    <div class="jyxxchildren-head">
                        <a-icon type="star" theme="filled" />
                        <div class="headxmlx">1:500现状工程图</div>
                    </div>
                    <div class="jyxxchildren-body">
                        <img src="/lsxmgl/alsxmgl/images/jyxx/blank-noData.png" style="width:50%;"/>
                        <div>暂无详细信息</div>
                        <div :style="{padding:'25px'}">
                            <a-button icon="search" @click="addywxx">完善项目信息</a-button>
                        </div>
                    </div>
                </div>
                <div class="jyxxchildren">
                    <div class="jyxxchildren-head">
                        <a-icon type="star" theme="filled" />
                        <div class="headxmlx">勘测定界图</div>
                    </div>
                    <div class="jyxxchildren-body">
                        <div class="jyxxchildren-body-content">
                            <div class="jyxxchildren-body-content-jdxx" v-for="(items,indexs) in jdList" :key="indexs" class="tablejdinfo" :class="[{'tableerror' : items.SFKFP == 'wk' && items.SFYSK !='是','tableorange' : items.SFKFP == 'yk' && items.SFYSK !='是'}]">
                                <div class="tablejdtitle">第{{indexs + 1}}收款节点</div>
                                <div>是否开发票:{{items.SFKFP == 'wk' ? '未开发票' : '已开发票'}}</div>
                                <div>收款时间:{{items.SKSJ == null || items.SKSJ == "" ? '暂未收款' : items.SKSJ.substring(0,11)}}</div>
                                <div>节点收款:{{items.SKJE}}元</div>
                                <div>实际收款:{{items.SJSKJE}}元</div>
                            </div>
                        </div>
                        <div class="jyxxchildren-body-edit">
                            <a-breadcrumb>
                                <a-breadcrumb-item href="">
                                    <a-icon type="line-chart" />
                                    <span>进度</span>
                                </a-breadcrumb-item>
                                <a-breadcrumb-item href="">
                                    <a-icon type="form" />
                                    <span>详情</span>
                                </a-breadcrumb-item>
                                <a-breadcrumb-item href="">
                                    <a-icon type="file-text" />
                                    <span>洽谈</span>
                                </a-breadcrumb-item>
                                <a-breadcrumb-item href="">
                                    <a-icon type="profile" />
                                    <span>合同</span>
                                </a-breadcrumb-item>
                            </a-breadcrumb>
                        </div>
                    </div>
                </div>
                <div class="jyxxchildren addchildren">
                    <a-icon type="plus"/>
                </div>
            </div>
        </div>
    </div>`,
    data(){
        return{
            jyxxList:[],//全部项目数组
            jdList:[],//进度数组
        }
    },
    mounted(){
        this.jyxxList = [
            {xmmc:'XXX项目',xmbh:'XMGL2021-09-06'},
            {xmmc:'XXX项目',xmbh:'XMGL2022-01-11'},
        ],
        this.jdList = [
            {xmmc:'XXX项目',SFKFP:'yk',SKSJ:'2022-10-19',SKJE:6500,SJSKJE:6000,SFYSK:'是'},
            {xmmc:'XXX项目',SFKFP:'wk',SKSJ:'',SKJE:8000,SJSKJE:0,SFYSK:'否'},
        ]
    },
    methods:{

    }
  })

css部分

.yjxxbox{
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: auto;
}
/* 每一个项目的窗口 */
.jyxxline{
    display: flex;
    align-items: center;
    height: 400px;
    width: 100%;
    margin: 10px;
    padding: 5px 6px;
}
/* 每个项目的标题信息 */
.jyxxtitle{
    height: 400px;
    width: 300px;
    background-color: #fff;
    border-radius: 2px;
    border: 1px solid #EBDFD5;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transition: all .2s cubic-bezier(.645,.045,.355,1);
}
/* 项目的项目名称和项目编号样式 */
.jyxxtitle-xmmc{
    color: blue;
    font-weight: bold;
    font-size: 24px;
}
.jyxxtitle-xmbh{
    font-weight: 400;
    font-size: 22px;
}
/* 每个子项目的项目窗体 */
.jyxxchildren{
    border-radius: 2px;
    height: 400px;
    width: 400px;
    margin: 0 10px;
    background-color: #fff;
    border: 1px solid #EBDFD5;
    transition: all .2s cubic-bezier(.645,.045,.355,1);
}
/* 每个子项目的标题和内容信息 */
.jyxxchildren-head{
    display: flex;
    padding: 0 8px;
    align-items: center;
    height: 50px;
    padding: 0 12px;
    font-size: 14px;
    margin-bottom: -1px;
    color: #000000d9;
    font-weight: 500;
    background: transparent;
    border-bottom: 1px solid #EBDFD5;
    border-radius: 2px 2px 0 0;
}
.jyxxchildren-body{
    height: calc(100% - 36px);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
.jyxxtitle:hover,.jyxxchildren:hover{
    cursor: pointer;
    box-shadow: 0 6px 16px -8px #00000014, 0 9px 28px #0000000d, 0 12px 48px 16px #00000008;
}

/* 子项目中的样式设置 */
.anticon-star{
    font-size: 28px;
    color: red;
    margin-right: 5px;
}
/* 子项目标题 */
.headxmlx{
    font-size: 20px;
    /* font-weight: bold; */
}
/* 子项目内容展示区间 */
.jyxxchildren-body-content{
    padding: 8px;
    width: 100%;
    height: 80%;
    border-bottom: 1px solid #EBDFD5;
}
/* 子项目内容下半部分按钮区域 */
.jyxxchildren-body-edit{
    width: 100%;
    height: 20%;
    display: flex;
    justify-content: center;
    align-items: center;
}
/* 添加子项目 */
.addchildren{
    display: flex;
    justify-content: center;
    align-items: center;
}
.anticon-plus{
    font-size: 56px;
}
/* 子项目内容信息展示--------start */
/* 进度 */
.jyxxchildren-body-content-jdxx{
    /* margin-top: 5px; */
}
.tablejdinfo{
    background-color: #e1f3d8;
    color: #67c23a;
    margin-bottom: 5px;
    border-radius: 5px;
    padding: 4px 5px;
}
/* 子项目内容信息展示--------end */
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
CSS实现翻牌效果动画可以使用CSS 3D转换和CSS动画来实现。以下是实现的步骤: 1. 创建一个容器,用于包含翻转的两个面。 2. 给容器添加一个透视效果,使其能够呈现出三维效果。 ``` .container { perspective: 1000px; } ``` 3. 创建两个面,分别用于显示正面和背面的内容,并将它们放置在容器中。 ``` <div class="container"> <div class="card"> <div class="front">正面</div> <div class="back">背面</div> </div> </div> ``` 4. 使用CSS 3D转换将背面旋转180度,并设置初始状态为不可见。 ``` .card { transform-style: preserve-3d; transition: all 0.5s ease; } .back { transform: rotateY(180deg); display: none; } ``` 5. 使用CSS动画在容器的鼠标悬停事件时触发翻转效果,并切换正反面的可见状态。 ``` .container:hover .card { transform: rotateY(180deg); } .container:hover .card .front { display: none; } .container:hover .card .back { display: block; } ``` 完整的代码如下: ``` <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>翻牌效果动画</title> <style> .container { perspective: 1000px; width: 200px; height: 200px; } .card { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: all 0.5s ease; } .front, .back { position: absolute; top: 0; left: 0; width: 100%; height: 100%; backface-visibility: hidden; } .front { background-color: #e74c3c; color: #fff; } .back { background-color: #2ecc71; color: #fff; transform: rotateY(180deg); display: none; } .container:hover .card { transform: rotateY(180deg); } .container:hover .card .front { display: none; } .container:hover .card .back { display: block; } </style> </head> <body> <div class="container"> <div class="card"> <div class="front">正面</div> <div class="back">背面</div> </div> </div> </body> </html> ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

神仙姐姐QAQ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值