利用HTML和CSS实现的浮动布局

代码如下

<!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>
    *{
     
      margin: 0;
      padding: 0;
    }
    .all{
     
      width: 960px;
      height: 1000px;
      margin: 0 auto;
    }
    
    .body_url{
     
      height: 80px;
      display: inline-block;
      margin-bottom: 10px;
      /* 去除换行空格距离 */
      font-size: 0;
    }
    .body_com{
     
      display: inline-block;
      text-align: center;
      line-height: 80px;
      background-color: rgb(171, 149, 149);
      font-size: 16px;
    }
    .logo{
     
      width: 200px;
    }
    .banner1{
     
      width: 540px;
      margin: 0 10px;
    }
    .banner2{
     
      width: 200px;
    }
    .menu{
     
      height: 30px;
      background-color: rgb(171, 149, 149);
      text-align: center;
      line-height: 30px;
      margin-bottom: 10px;
    }
    .nav_left{
     
      width: 760px;
      float: left;
      font-size: 0;
    }
    .left_one{
     
      display: inline-block;
      width: 368px;
      height: 198px;
      text-align: center;
      line-height: 100px;
      border: 1px solid black;
      margin-right: 10px;
      margin-bottom: 10px;
      font-size: 16px;
    }
   
    .left_two{
     
      display: inline-block;
      width: 178px;
      height: 198px;
      text-align: center;
      line-height: 100px;
      border: 1px solid black;
      margin-right: 10px;
      font-size: 16px;
    }
    .nav_right{
     
      width: 200px;
      float: right;
      font-size: 0;
    }
    .left_three{
     
      display: inline-block;
      width: 198px;
      height: 128px;
      text-align: center;
      line-height: 100px;
      border: 1px solid black;
      margin-bottom: 10px;
      font-size: 16px;
    }
    .foot_url{
     
      /* 清除浮动 */
      clear: both;
      height: 60px;
      text-align: center;
      line-height: 60px;
      background-color: rgb(171, 149, 149);
    }
  </style>
</head>
<body>
  <div class="all">
    <!-- 头部 -->
    <div class="body_url">
      <div class="body_com logo">logo</div>
      <div class="body_com banner1">banner1</div>
      <div class="body_com banner2">banner2</div>
    </div>
    <!-- 菜单 -->
    <div class="menu">
      菜单
    </div>
    <!-- 栏目 -->
    <div class="nav_url">
      <!-- 左边栏目 -->
      <div class="nav_left">
        <!-- top -->
        <span class="left_one">栏目一</span>
        <span class="left_one">栏目二</span>
        <!-- bottom -->
        <span class="left_two">栏目三</span>
        <span class="left_two">栏目四</span>
        <span class="left_two">栏目五</span>
        <span class="left_two">栏目六</span>
      </div>
      <!-- 右边栏目 -->
      <div class="nav_right">
        <span class="left_three">栏目七</span>
        <span class="left_three">栏目八</span>
        <span class="left_three">栏目九</span>
      </div>
    </div>
    <!-- 页脚 -->
    <div class="foot_url">
      页脚
    </div>
  </div>
</body>
</html>

这是UI设计图
在这里插入图片描述
下面为实现的效果图
在这里插入图片描述

相关推荐

  1. CSS中页面布局案例-利用浮动

    2024-01-17 22:24:01       40 阅读
  2. CSS浮动(float)布局效果

    2024-01-17 22:24:01       30 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-17 22:24:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-17 22:24:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-17 22:24:01       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-17 22:24:01       20 阅读

热门阅读

  1. 深度解析 ThreadLocal 的多重应用场景

    2024-01-17 22:24:01       33 阅读
  2. C++ 并发编程 | 锁

    2024-01-17 22:24:01       26 阅读
  3. SpringBoot ES 聚合后多字段加减乘除

    2024-01-17 22:24:01       31 阅读
  4. ffmpeg 基础知识

    2024-01-17 22:24:01       35 阅读
  5. 京东云无线宝一代64G加速版刷机记录

    2024-01-17 22:24:01       109 阅读
  6. 每日coding

    2024-01-17 22:24:01       36 阅读
  7. LeetCode 37. 解数独

    2024-01-17 22:24:01       32 阅读
  8. 基于stm32的智能衣柜系统设计(毕业设计)

    2024-01-17 22:24:01       40 阅读
  9. GoLang刷题之leetcode

    2024-01-17 22:24:01       29 阅读
  10. 用Python做数据分析之生成数据表

    2024-01-17 22:24:01       29 阅读
  11. openssl3.2 - 官方demo学习 - signature - rsa_pss_hash.c

    2024-01-17 22:24:01       25 阅读
  12. ssl解码

    2024-01-17 22:24:01       33 阅读