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>
相关推荐
江城开朗的豌豆5 分钟前
CSS篇:APP适配终极方案:Flexible、REM、Viewport全解析
前端
pink大呲花6 分钟前
Vue.js 中 v-model 的使用及其原理
前端·javascript·vue.js
打野赵怀真13 分钟前
第 114 题:找出字符串中连续出现最多的字符和个数
前端·javascript
xll_00716 分钟前
VUE3+TS+elementplus+Django+MySQL实现从前端增加数据存入数据库,并显示在前端界面上
前端·python·mysql·typescript·django·vue
wordbaby18 分钟前
通过共享 Promise 解决前端重复请求-最终篇
前端·axios·promise
uhakadotcom18 分钟前
刚刚发布的next.js 15.3提供了什么新能力,怎么用?
前端·javascript·面试
hepherd19 分钟前
Vue学习笔记 - 深入组件 - 注册,透传Attribute,异步组件
前端·vue.js
用泥种荷花20 分钟前
【记一忘三二】babel
前端
bysking20 分钟前
【26-请求缓存】js实现一个请求缓存的功能-bysking
前端·javascript
宇宙无敌超级暴龙大战士WJL21 分钟前
Vue3 运行时解析SFC单文件模板字符串
前端