css实现卡片突出焦点功能


html

typescript 复制代码
<body>
    <div class="container">

        <ul>
            <li>
                <div class="img-box">
                    <img src="https://snail-staging.oss-cn-shanghai.aliyuncs.com/upload-pc/school-3/care/picker/20220830/20220830145148_39j3.jpg" />
                </div>

                <div class="content">
                    <h3 class="rank">
                        <small>#</small>1
                    </h3>

                    <h4>join</h4>

                    <p>测试</p>
                </div>
            </li>

            <li>
                <div class="img-box">
                    <img src="https://snail-staging.oss-cn-shanghai.aliyuncs.com/upload-pc/school-3/care/picker/20220830/20220830145412_zm5c.jpg" />
                </div>

                <div class="content">
                    <h3 class="rank">
                        <small>#</small>2
                    </h3>

                    <h4>hill</h4>

                    <p>测试2</p>
                </div>
            </li>

            <li>
                <div class="img-box">
                    <img src="https://snail-staging.oss-cn-shanghai.aliyuncs.com/upload-pc/school-3/care/picker/20220830/20220830145653_ns73.jpg" />
                </div>

                <div class="content">
                    <h3 class="rank">
                        <small>#</small>3
                    </h3>

                    <h4>baby</h4>

                    <p>测试3</p>
                </div>
            </li>
        </ul>
    </div>
</body>

css

typescript 复制代码
  <style>
        /*google-fonts*/
        @import url('https://fonts.googleapis.com/css?family=Poppins:200,300,400,500,600,700,800,900&display=swap');

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        ul li {
            list-style: none;
        }

        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        body {
            font-family: 'Poppins', sans-serif;
            color: #333;

            min-height: 100vh;
            background-color: #f5f5f5;

            display: flex;
            justify-content: center;
            align-items: center;
        }

        .container {
            padding: 20px;
        }

        .container h2 {
            font-size: 1.75em;
            margin-bottom: 20px;
            text-align: center;
        }

        ul {
            min-width: 300px;
            /* min-width: 350px; */
        }

        ul:hover li {
            filter: blur(5px);
            opacity: 0.3;
        }

        ul li {
            position: relative;

            display: flex;
            column-gap: 10px;
            padding: 10px;
            margin-block: 10px;
            overflow: hidden;

            background-color: #fff;
            border-radius: 10px;

            cursor: pointer;
            transition: 0.5s;
        }

        ul li:hover {
            box-shadow: -10px 20px 35px rgba(0, 0, 0, 0.15);
            transform: scale(1.15);
            filter: blur(0);
            opacity: 1;
        }

        ul li .img-box {
            width: 60px;
            height: 60px;

            border-radius: 10px;
            overflow: hidden;
        }

        ul li .content {
            display: flex;
            flex-direction: column;
            justify-content: center;
        }

        ul li .content .rank {
            position: absolute;
            right: -50px;

            color: #03a9f4;
            font-size: 2em;

            transition: right 0.5s;
        }

        ul li .content .rank small {
            font-weight: 500;
            opacity: 0.3;
        }

        ul li:hover .content .rank {
            right: 20px;
        }

        ul li .content h4 {
            font-weight: 600;
            line-height: 1.2em;
        }

        ul li .content p {
            font-size: 0.75em;
        }
    </style>
相关推荐
一个处女座的程序猿O(∩_∩)O5 分钟前
完成第一个 Vue3.2 项目后,这是我的技术总结
前端·vue.js
mubeibeinv6 分钟前
项目搭建+图片(添加+图片)
java·服务器·前端
逆旅行天涯12 分钟前
【Threejs】从零开始(六)--GUI调试开发3D效果
前端·javascript·3d
m0_7482552634 分钟前
easyExcel导出大数据量EXCEL文件,前端实现进度条或者遮罩层
前端·excel
web147862107231 小时前
C# .Net Web 路由相关配置
前端·c#·.net
m0_748247801 小时前
Flutter Intl包使用指南:实现国际化和本地化
前端·javascript·flutter
飞的肖1 小时前
前端使用 Element Plus架构vue3.0实现图片拖拉拽,后等比压缩,上传到Spring Boot后端
前端·spring boot·架构
青灯文案11 小时前
前端 HTTP 请求由 Nginx 反向代理和 API 网关到后端服务的流程
前端·nginx·http
m0_748254881 小时前
DataX3.0+DataX-Web部署分布式可视化ETL系统
前端·分布式·etl
ZJ_.2 小时前
WPSJS:让 WPS 办公与 JavaScript 完美联动
开发语言·前端·javascript·vscode·ecmascript·wps