2022-03-03 html网页布局练习(二):使用float浮动+html5新增标签进行网页布局

设计图

https://s3.bmp.ovh/imgs/2023/02/10/f04eca2ec8533891.jpg

页面构成和思路
  • 页面由头部header+轮拨图banner+选项卡片section+案例case+客户client+关于我们&新闻aboutUs&news+底部footer组成
  • 头部底部等等用到了h5新增标签
  • 使用float浮动进行盒模型的水平布局,使用内外边距padding和margin进行上下左右间距的拉开
  • 在margin:top塌陷的地方是通过改为设置padding:top再将height减去相应像素来实现的
  • 网页在浏览器中的居中显示是通过设置html的宽度100%,body设置一个固定宽度然后margin:0 auto;来实现的
完整代码
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>BEANCMS</title>
    <link rel="stylesheet" href="./font/iconfont.css" />
    <style>
      * {
     
        margin: 0;
        padding: 0;
      }
      ul,
      li {
     
        list-style-type: none;
      }
      a{
     
        text-decoration: none;
      }
      h1,
      h2,
      h3,
      h4,
      h5,
      h6 {
     
        font-weight: normal;
      }
      html {
     
        width: 100%;
      }
      body {
     
        width: 1146px;
        margin: 0 auto;
        /* overflow: hidden; */
      }
      /* 1.header头部 */
      header {
     
        width: 100%;
        height: 60px;
        background: #e83928;
        margin: 0 auto;
      }
      header > span {
     
        float: left;
        margin-left: 70px;
        font-size: 20px;
        color: #fff;
        font-family: SimHei;
        font-weight: 900;
        line-height: 60px;
      }
      header > ul {
     
        float: left;
        margin-left: 156px;
      }
      header li {
     
        float: left;
        line-height: 60px;
        font-size: 14px;
        font-weight: 600;
        margin-right: 44px;
      }
      header a{
     
        color:#fff;
      }
      header a:active{
     
        text-decoration: underline;
      }
      .lianxi {
     
        float: right;
        margin-right: 65px;
      }
      #weibo,
      #qq,
      #phone,
      .tel {
     
        float: left;
        color: #fff;
        line-height: 60px;
        margin-right: 10px;
        font-weight: 600;
      }
      /* 2.banner */
      .banner {
     
        width: 100%;
        height: 522px;
      }
      /* 3.section */
      section {
     
        height: 226px;
      }
      .container {
     
        width: 16.5%;
        height: 186px;
        border-right: 1px dashed #565656;
        color: #666666;
        text-align: center;
        margin-top: 16px;
        margin-bottom: 32px;
        float: left;
      }
      .container:last-child {
     
        border: none;
      }
      .container > .iconfont {
     
        font-size: 50px;
      }
      .container h3 {
     
        font-size: 16px;
        line-height: 34px;
        color: #7c7c7c;
      }
      .container h5 {
     
        font-size: 14px;
        line-height: 24px;
      }
      /* 4.case */
      #case {
     
        width: 100%;
        height: 490px;
        float: none;
        background: #eeeeee;
      }
      .title {
     
        /* 减去padding值 */
        width: calc(100% - 80px);
        /* height: 102px; */
        height: 34px;
        /* 避开margin-top塌陷 */
        padding: 42px 8px 26px 72px;
      }
      .eng {
     
        font-size: 34px;
        font-weight: 900;
      }
      .cn {
     
        font-size: 20px;
      }
      .box1,
      .box2,
      .box3 {
     
        width: 320px;
        height: 320px;
        background: #fff;
        float: left;
        margin-left: 20px;
      }
      .box1 {
     
        margin-left: 72px;
      }
      .caseBox .text {
     
        margin: 6px 10px;
      }
      .caseBox h4 {
     
        height: 34px;
        line-height: 34px;
        font-size: 14px;
        border-bottom: 1px solid #e3e3e3;
      }
      .caseBox h6 {
     
        margin-top: 6px;
        font-size: 12px;
        line-height: 20px;
        color: #8384c0;
      }
      .caseBox p {
     
        float: right;
        font-size: 10px;
        color: #959597;
      }
      /* 5.client */
      #client {
     
        width: 100%;
        height: 254px;
      }
      .clientBox {
     
        width: 194px;
        height: 152px;
        border: 1px solid #afafaf;
        float: left;
        margin-left: 8px;
        position: relative;
      }
      .clientBox > img {
     
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        margin: auto;
      }
      .first {
     
        margin-left: 72px;
      }
      /* 6.aboutUs和news */
      article {
     
        width: calc(100% - 190px);
        /* width:100%; */
        height: 392px;
        padding-left: 72px;
        padding-top: 52px;
        /* border: 1px solid green; */
      }
      .aboutUs {
     
        border-right: 1px dashed #565656;
        padding-right: 40px;
        /* background: pink; */
      }
      .news {
     
        margin-left: 40px;
        margin-right: -40px
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

前端OnTheRun

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值