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>
相关推荐
爱喝白开水a1 小时前
前端AI自动化测试:brower-use调研让大模型帮你做网页交互与测试
前端·人工智能·大模型·prompt·交互·agent·rag
董世昌411 小时前
深度解析ES6 Set与Map:相同点、核心差异及实战选型
前端·javascript·es6
吃杠碰小鸡2 小时前
高中数学-数列-导数证明
前端·数学·算法
kingwebo'sZone2 小时前
C#使用Aspose.Words把 word转成图片
前端·c#·word
xjt_09012 小时前
基于 Vue 3 构建企业级 Web Components 组件库
前端·javascript·vue.js
我是伪码农3 小时前
Vue 2.3
前端·javascript·vue.js
夜郎king3 小时前
HTML5 SVG 实现日出日落动画与实时天气可视化
前端·html5·svg 日出日落
夏幻灵4 小时前
HTML5里最常用的十大标签
前端·html·html5
Mr Xu_4 小时前
Vue 3 中 watch 的使用详解:监听响应式数据变化的利器
前端·javascript·vue.js
未来龙皇小蓝4 小时前
RBAC前端架构-01:项目初始化
前端·架构