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>
相关推荐
秋子aria2 分钟前
模块的原理及使用
前端·javascript
菜市口的跳脚长颌2 分钟前
一个 Vite 打包配置,引发的问题—— global: 'globalThis'
前端·vue.js·vite
胖虎2652 分钟前
实现无缝滚动无滚动条的 Element UI 表格(附完整代码)
前端·vue.js
小左OvO3 分钟前
基于百度地图JSAPI Three的城市公交客流可视化(一)——线路客流
前端
星链引擎5 分钟前
企业级智能聊天机器人 核心实现与场景落地
前端
GalaxyPokemon7 分钟前
PlayerFeedback 插件开发日志
java·服务器·前端
爱加班的猫7 分钟前
深入理解防抖与节流
前端·javascript
自由日记22 分钟前
学习中小牢骚1
前端·javascript·css
泽泽爱旅行25 分钟前
业务场景-opener.focus() 不聚焦解决
前端
VOLUN30 分钟前
Vue3 选择弹窗工厂函数:高效构建可复用数据选择组件
前端·javascript·vue.js