网站常用的卡片布局

简介: 网站常用的卡片布局


左图右文

这种布局最常见的

实现思路

  1. 大盒子 里面 套两个 小盒子
  2. 设置大盒子flex 布局
  3. 分别在两个盒子放入 图片 文字 即可

效果

因为设置了媒体响应 当屏幕宽度小于800像素大小 就变成纵向布局

详细代码

Html

 <div class="box">
        <!-- 左图 -->
        <div class="img"></div>
        <!-- 文字 -->
        <div class="text-Content">
            <div class="title">So Like Fun Weekend</div>
            <div class="content">
                Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquid eligendi vel veritatis debitis minima
                dignissimos nihil incidunt saepe maiores ducimus ex at sequi voluptatum, eaque, alias illo cumque
                assumenda quam?
            </div>
            <!-- 按钮 -->
            <button class="btn">Learn More</button>
        </div>
    </div>

CSS

 @font-face {
            font-family: "站酷酷黑 Regular";
            font-weight: 400;
            src: url("//at.alicdn.com/wf/webfont/pXW6WcZ4aH3n/wrZZ7zVs0VrlZEOKyNJqi.woff2") format("woff2"),
                url("//at.alicdn.com/wf/webfont/pXW6WcZ4aH3n/3fDVYyJQ0o7NFKAX_5-Z0.woff") format("woff");
            font-display: swap;
        }

        * {
            font-family: "站酷酷黑 Regular";
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            width: 100%;
            height: 100vh;
            /* flex 子元素 水平居中对其*/
            display: flex;
            justify-content: center;
            align-items: center;
            /* 渐变色背景 */
            background: linear-gradient(to right, #1565C0, #b92b27);
        }

        .box {
            display: flex;
            width: 65%;
            height: 65%;
            padding: 50px;
        }

        .img {
            flex: 1;
            background: url(./img/3.jpg);
            background-size: cover;
            background-position: center center;
            border-radius: 12px;
            transition: all 1s linear;
        }

        .img:hover {
            filter: saturate(250%);
        }

        .text-Content {
            flex: 1;
            margin-left: 7.4vw;
            overflow: hidden;
        }

        .title {
            font-size: 2rem;
            margin-bottom: 1.3em;
        }

        .content {
            font-size: 1.2rem;
        }

        .btn {
            margin-top: 20%;
            width: 150px;
            height: 50px;
            border-radius: 20px;
            background-color: rgba(0, 0, 0, 0.607);
            color: #ffffffc2;
            transition: all 0.8s;
            cursor: pointer;
            font-size: 1rem;
            border: 0;
        }

        .btn:hover {
            background-color: rgba(255, 255, 255, 0.747);
            color: rgba(0, 0, 0, 0.795);
        }

        @media screen and (max-width: 800px) {
            .box {
                width: 90%;
                height: 100vh;
                flex-direction: column;
            }

            .img {
                margin-bottom: 16px;
            }

            .text-Content {
                font-size: 15px;
                margin-left: 0;
            }

            .title {
                font-size: 1.2rem;
                margin-bottom: 1em;
            }

            .content {
                font-size: 1rem;
            }
        }

悬停图片 显示文本内容

实现思路

  • 只要思想是 使用的 hover + transition + 滤镜
  • hover之后 将图片的光度调低 文字的透明度设置为 1

效果

文字环绕图片

 <div class="main">
        <div class="head">
            <div class="text">
                <div class="title">How Image Beautiful</div>
                <div class="content">Lorem ipsum dolor, sit amet consectetur adipisicing elit. Recusandae maxime

                </div>
            </div>
        </div>


       
        <div class="body">
            <div class="left">
                <div class="icon">Happy</div>
                <div class="content">Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque, minima
                    reprehenderit. Consequuntur sed quisquam aliquid vitae quae officiis id voluptates unde voluptas,
                </div>

                <div class="icon">Slow</div>
                <div class="content">Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque, minima
                    reprehenderit. Consequuntur sed quisquam aliquid vitae quae officiis id voluptates unde voluptas,
                </div>
            </div>
            <!-- 图片-- 插图  -->
            <div class="middle"></div>
            <!-- 右边 和左边很相似 -->
            <div class="right">
                <div class="icon">Fast</div>
                <div class="content">Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque, minima
                    reprehenderit. Consequuntur sed quisquam aliquid vitae quae officiis id voluptates unde voluptas,
                </div>

                <div class="icon">Money</div>
                <div class="content">Lorem ipsum dolor sit amet consectetur adipisicing elit. Eaque, minima
                    reprehenderit. Consequuntur sed quisquam aliquid vitae quae officiis id voluptates unde voluptas,
                </div>
            </div>
        </div>

        <div class="footer">
            <div class="text">
                <div class="icon">Cool</div>
                <div class="content">
                    Lorem ipsum dolor sit amet consectetur adipisicing elit. Aut rem minus rerum, perspiciatis illum
                    minima,
                </div>
                <button class="btn">Lorem More</button>

            </div>


        </div>
    </div>


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

        body {
            width: 100%;
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            background-image: url(./WebSite设计用图//2.jpg);
            background-size: cover;
            background-position: center center;
            border-radius: 20px;
            backdrop-filter: blur(5px)
        }

        .main {
            width: 80%;
            height: 80%;
            /* 添加毛玻璃效果 */
            background-color: rgba(112, 112, 112, 0.5);
            border-radius: 10px;
        }

        /* 总体下来的是三个纵向布局 分别为 头 身体 脚 */
        /* 先从头部开始搭建布局 */
        .head {
            /* head 布局里面又分为标题 和 内容 两个模块 纵向布局  */
            /* 可以参考原型图 得知 是居中水平对其  我们可以flex一下*/
            display: flex;
            justify-content: center;
            align-items: center;

            /* 给个宽高  分别宽 为 父级的 100%* 高 大概是 20%*/
            width: 100%;
            height: 20%;
        }

        .head .text {
            width: 30%;
            height: 100%;
            /* 然后在这个文本盒子里面 包含了标题 和 内容 要水平居中 */
            text-align: center;

        }

        .head .title {
            font-weight: 700;
            font-size: 32px;
            /* 标题 和 内容 要有上下边距 设置margin */
            margin-bottom: 16px;
        }


        /* 下面 我们开始进行 最复杂的一块 就是 中间部分的搭建 */
        /* 我们可以看出来 中间部分 又可以分为 左  中  右 三部分   */
        /* 我们只要依次按照这个顺序 来搭建 就可以了 全程 flex 一把梭 */

        .body {
            display: flex;
            width: 100%;
            height: 50%;

        }

        .left {
            /* 使用flex 布局 调整为 两端对其 */
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            flex: 0.8;
            padding: 16px;
        }

        .left .icon {
            text-align: center;
            font-size: 30px;
            font-weight: 600;
        }

        .left .content {
            font-size: 14px;
        }

        .middle {
            flex: 1;
            /* 设置图片完整展出 */
            background-image: url(./WebSite设计用图//2.jpg);
            background-size: cover;
            background-position: center center;
            border-radius: 20px;

        }

        .right {
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding: 16px;
            flex: 0.8;
        }

        .right .icon {
            text-align: center;
            font-size: 30px;
            font-weight: 600;
        }

        .right .content {
            font-size: 14px;
        }

        .footer {

            display: flex;
            align-items: center;
            justify-content: center;
            width: 100%;
            height: 20%;
        }

        .footer .text {
            margin-top: 16px;
            width: 30%;
            height: 100%;
            /* 然后在这个文本盒子里面 包含了标题 和 内容 要水平居中 */
            text-align: center;
        }

        .footer .icon {
            font-weight: 700;
            font-size: 32px;
            /* 标题 和 内容 要有上下边距 设置margin */
            margin-bottom: 16px;

        }

        .footer .content {
            margin-bottom: 12px;
            font-size: 14px;
        }

        .footer .btn {
            width: 150px;
            height: 35%;
            border: 0;
            background-color: #233333;
            color: #fff;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.5s;

        }

最终效果:

image.png

image.png

image.png


目录
相关文章
|
JavaScript 内存技术
fnm 安装、卸载与使用(详细步骤)
fnm 安装、卸载与使用(详细步骤)
4013 0
|
SQL 前端开发 数据可视化
MySQL Workbench 使用教程 - 如何使用 Workbench 操作 MySQL / MariaDB 数据库中文指南
MySQL Workbench 是一款专门为 MySQL 设计的可视化数据库管理软件,我们可以在自己的计算机上,使用图形化界面远程管理 MySQL 数据库。有关 MySQL 远程管理软件,你可以选择 Windows 下的 HeidiSQL,MacOS 下的 Sequel Ace 或者 MySQL 官方推出的跨平台客户端 MySQL Workbench 。
12788 0
|
人工智能 前端开发 流计算
前端的同学,终于要起飞啦,Github 6.3k star + ,免费可商用的UI元素库!!!
小华同学推荐:galaxy 是一个免费可商用的开源 UI 元素库,收录超 3,000 个组件,支持 CSS 与 Tailwind 双格式,兼容 Figma/React/HTML,助力高效开发与设计协作。
1547 7
|
存储 缓存 资源调度
# Qwen3-8B 与 ChatGPT-4o Mini 的 TTFT 性能对比与底层原理详解
Qwen3-8B 是通义实验室推出的80亿参数模型,支持32K上下文,采用FP8量化和CUDA优化,提升推理效率;ChatGPT-4o Mini 为OpenAI轻量模型,参数约3.8B,支持128K上下文,通过蒸馏技术实现低延迟。两者在TTFT、长文本处理和部署优化上各有优势,适用于不同应用场景。
2150 9
|
存储 人工智能 Serverless
智能理解 PPT 内容,快速生成讲解视频
本方案利用函数计算 FC 部署 Web 应用,调用百炼模型服务实现 PPT 到视频的自动转换。视觉模型智能理解 PPT 图文内容,快速生成相匹配的解说词;文本模型对解说词进行优化,提高其可读性和吸引力;语音模型则根据解说词生成生动流畅的旁白音频。整个过程高度集成,只需一键操作,系统即可自动整合图片、文本和音频素材,快速生成对应讲解视频。
2359 18
|
安全 应用服务中间件 PHP
中间件漏洞
中间件漏洞
|
Apache 项目管理 流计算
祝贺!两位 Apache Flink PMC 喜提 Apache Member
目前,国内(华人)近 30 位 Apache Member 中,有 3 位是 Apache Flink 的核心贡献者。他们热爱开源也为开源贡献,不仅积极参与社区与其他 PMC 成员共同规划、主导 Apache Flink 的发展,更活跃在多个开源项目,持续为开源社区做贡献。
|
前端开发 网络协议 Go
为什么ChatGPT选择了SSE,而不是WebSocket?
为什么ChatGPT选择了SSE,而不是WebSocket?
1599 2
|
数据可视化 安全 数据挖掘
开源数据可视化分析工具DataEase本地部署并实现远程访问
开源数据可视化分析工具DataEase本地部署并实现远程访问
|
机器学习/深度学习 自然语言处理 语音技术
文字转语音
文字转语音
2756 1