html中一个div中平均分三个盒子

html中一个div中平均分三个盒子

html中一个div中平均分三个盒子,大小自适应,随着界面的大小而改变大小
1、截图展示
在这里插入图片描述
2.代码部分

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    body {
   
      margin: 0; /* 重置默认的body边距 */
    }

    .container {
   
      display: flex;
      justify-content: space-between;
      border: 3px solid #D4E3FC;
      border-radius: 10px;
      padding: 20px; /* 添加上下左右相等的边距 */
      box-sizing: border-box; /* 让padding不会撑大容器 */
      overflow: hidden; /* 用于清除浮动,防止子元素溢出 */
    }

    .box {
   
      width: calc(33.33% - 20px); /* 三个盒子平分容器宽度,并留出间隙 */
      box-sizing: border-box; /* 防止盒子宽度溢出 */
      background-color: blue; /* 设置盒子颜色为蓝色 */
      margin-bottom: 20px; /* 间隙的高度,可根据需要调整 */
    }

    .monitor {
   
      height: 100px; /* 设置盒子高度 */
    }
  </style>
  <title>Three Boxes in Container</title>
</head>
<body>
  <div class="container" id="boxContainer">
    <div class="box">
      <div class="monitor">
        <!-- 内容 -->
      </div>
    </div>
    <div class="box">
      <div class="monitor">
        <!-- 内容 -->
      </div>
    </div>
    <div class="box">
      <div class="monitor">
        <!-- 内容 -->
      </div>
    </div>
  </div>
</body>
</html>

相关推荐

  1. htmldiv标签

    2023-12-09 05:24:02       16 阅读
  2. HTMLdiv内容垂直居中显示

    2023-12-09 05:24:02       32 阅读
  3. 【CSS】DIV在同一行平分宽度的五种实现方法

    2023-12-09 05:24:02       17 阅读
  4. 【无标题】html使用div标签的坏处

    2023-12-09 05:24:02       16 阅读
  5. Vue3如何将一个div进行拖拽

    2023-12-09 05:24:02       22 阅读
  6. 【Vue】Vue使一个div铺满全屏

    2023-12-09 05:24:02       19 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-09 05:24:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-09 05:24:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-09 05:24:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-09 05:24:02       20 阅读

热门阅读

  1. 【Python】按升序排列 Excel 工作表

    2023-12-09 05:24:02       39 阅读
  2. Neo4j介绍

    2023-12-09 05:24:02       37 阅读
  3. pdf转png的两种方法

    2023-12-09 05:24:02       36 阅读
  4. 算法工程师-机器学习面试题总结(5)

    2023-12-09 05:24:02       28 阅读
  5. 使用poi-tl填充word模板,并转化为pdf输出

    2023-12-09 05:24:02       23 阅读
  6. tensorflow 常用代码片段

    2023-12-09 05:24:02       40 阅读
  7. Spring Cloud Gateway中对admin端点进行认证

    2023-12-09 05:24:02       43 阅读
  8. 【C++ mutable使用】

    2023-12-09 05:24:02       39 阅读
  9. ZooKeeper学习二

    2023-12-09 05:24:02       42 阅读
  10. 通信协议 远程调用RPC

    2023-12-09 05:24:02       30 阅读