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>
相关推荐
qcx2326 分钟前
【系统学AI】25 论文导读 ①:两篇改变 AI 的开山之作——Attention Is All You Need & ReAct
前端·人工智能·react.js·transformer
kyriewen1 小时前
大文件上传最全指南:分片、断点续传、秒传,一篇就够了
前端·javascript·面试
郑洁文2 小时前
基于Python的Web命令执行漏洞自动化检测系统
前端·python·网络安全·自动化
新酱爱学习2 小时前
手搓 10 个 Skill 后,我把重复劳动收敛成了一套零依赖 CLI 工具
前端·javascript·人工智能
IT_陈寒3 小时前
Python的线程池居然把我坑在了垃圾回收这块
前端·人工智能·后端
研☆香3 小时前
es6新特性功能介绍(一)
前端·ecmascript·es6
陈_杨3 小时前
鸿蒙开发-疾阅App阅读训练功能技术解析
前端·javascript
zhangxingchao3 小时前
AI应用开发八:RAG相关技术总结
前端·人工智能·后端
凌涘4 小时前
依托 BEM 规范深度剖析 WeUI 微信按钮组件开发与实现
前端·微信