css 用flex做成田字型

哈喽,各位小伙伴!今天给大家来css控制div完成田字型样式,来,看看下面的效果图:

一看就知道你们想要代码了,不急。代码:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=<device-width>, initial-scale=1.0">
    <title>Document</title>

    <style>
        #one {
            width: 250px;
            height: 300px;
            /* background: blue; */
            float: left;
        }

        #two {
            width: 250px;
            height: 300px;
            /* background: red; */
        }
    </style>
</head>
<body>
    <div class="container" style=" justify-content: center; display: flex;">
        <div id="one" style=" display: flex;flex-direction: column;">
           
            <div style="height: 50%; width: 100%; display: flex; flex-direction: column">
                <div class="img-tip"><div class="img-tip">推至商品</div></div>
                <div style="display: flex;align-items: center;justify-content: space-between;flex: 1;">
                    <div style="flex: 1;height: 100%;"">
                        
                      <img src="C:\Users\Administrator\Pictures\Screenshots\3.jpg" style="width: 100%; height: 100%; object-fit: cover; display: block; margin: 0 auto;" alt="Your Image"> <!-- 替换成你的图片路径 -->
                  
                    </div>
                    <div style="flex: 1;height: 100%;"">
                        
                        <img src="C:\Users\Administrator\Pictures\Screenshots\3.jpg" style="width: 100%; height: 100%; object-fit: cover; display: block; margin: 0 auto;" alt="Your Image"> <!-- 替换成你的图片路径 -->
                    
                      </div>
                </div>
            </div>

            <div style="height: 50%; width: 100%; display: flex; flex-direction: column">
                <div class="img-tip"><div class="img-tip">推至商品</div></div>
                <div style="display: flex;align-items: center;justify-content: space-between;flex: 1;">
                    <div style="flex: 1;height: 100%;display: flex;justify-content: center;align-items: center;">
                        
                      <img src="C:\Users\Administrator\Pictures\Screenshots\3.jpg" style="object-fit: cover; display: block; margin: 0 auto;" alt="Your Image"> <!-- 替换成你的图片路径 -->
                  
                    </div>
                 
                </div>
            </div>

        </div>

        <div id="two" style=" display: flex;flex-direction: column;">
    

            <div style="height: 50%; width: 100%; display: flex; flex-direction: column">
              <div class="img-tip"><div class="img-tip">推至商品</div></div>
              <div style="display: flex;align-items: center;justify-content: space-between;flex: 1;">
                  <div style="flex: 1;height: 100%;"">
                      
                    <img src="C:\Users\Administrator\Pictures\Screenshots\1.jpg" style="width: 100%; height: 100%; object-fit: cover; display: block; margin: 0 auto;" alt="Your Image"> <!-- 替换成你的图片路径 -->
                
                  </div>
                  <div style="flex: 1;height: 100%;"">
                      
                      <img src="C:\Users\Administrator\Pictures\Screenshots\1.jpg" style="width: 100%; height: 100%; object-fit: cover; display: block; margin: 0 auto;" alt="Your Image"> <!-- 替换成你的图片路径 -->
                  
                    </div>
              </div>
          </div>

        
          <div style="height: 50%; width: 100%; display: flex; flex-direction: column">
              <div class="img-tip"><div class="img-tip">推至商品</div></div>
              <div style="display: flex;align-items: center;justify-content: space-between;flex: 1;">
                  <div style="flex: 1;height: 100%;"">
                      
                    <img src="C:\Users\Administrator\Pictures\Screenshots\1.jpg" style="width: 100%; height: 100%; object-fit: cover; display: block; margin: 0 auto;" alt="Your Image"> <!-- 替换成你的图片路径 -->
                
                  </div>
                  <div style="flex: 1;height: 100%;"">
                      
                      <img src="C:\Users\Administrator\Pictures\Screenshots\1.jpg" style="width: 100%; height: 100%; object-fit: cover; display: block; margin: 0 auto;" alt="Your Image"> <!-- 替换成你的图片路径 -->
                  
                    </div>
              </div>
          </div>

        </div>

    </div>
</body>
</html>
相关推荐
2301_816374334 分钟前
服务访问的用户认证
前端·网络
XS0301064 分钟前
从浏览器到互联网的完整数据流
前端·数据库·servlet·交互
hhb_61810 分钟前
MATLAB数值计算与数据可视化核心技术梳理及实战应用案例解析
前端
lichenyang45311 分钟前
从零理解微前端:基于 React + Vite + qiankun 的子应用切换 Demo
前端·react.js·状态模式
2601_9577808424 分钟前
AI智能体时代:为什么HTML正在取代Markdown成为新一代输出标准
大数据·前端·人工智能·gpt·html·claude
2301_815279521 小时前
如何实现C++ Web 自动化测试实战:常用函数全解析与场景化应用指南
开发语言·前端·c++
代码不停1 小时前
Spring Web MVC
前端·spring·mvc
倾颜7 小时前
从 textarea 到 AI 输入框:用 Tiptap 实现 / 命令、@ 引用和结构化请求
前端·langchain·next.js
kyriewen8 小时前
程序员连夜带团队跑路,省了23万:这AI太贵,真的用不起了
前端·javascript·openai
kyriewen9 小时前
你写的代码没有测试,就像出门不锁门——Jest + Testing Library 从入门到不慌
前端·单元测试·jest