zoukankan      html  css  js  c++  java
  • margin外边距问题

    1 、上下边距会叠加

    1. !DOCTYPE html>
      <html>
      <head>
      <m<etacharset="UTF-8">
      <title></title>
      <style>
      .box1{
      width:500px;
      height:300px;
      background: blue;
      margin-bottom:30px;
      }
      .box2{
      width:300px;
      height:100px;
      background:#ffff00;
      margin-top:30px;
      }
      </style>
      </head>
      <body>
      <divclass="box1"></div>
      <divclass="box2"></div>
      </body>
      </html>

    2、父级包含子级的时候,子级的margin-top会传递给父级,可以使用父级的padding替代自己的margin。
    1. <!DOCTYPE html>
      <html>
      <head>
      <metacharset="UTF-8">
      <title></title>
      <style>
      .box1{
      width:500px;
      height:300px;
      background: blue;
      }
      .box2{
      width:300px;
      height:100px;
      background:#ffff00;
      margin-top:30px;
      }
      </style>
      </head>
      <body>
      <divclass="box1">
      <divclass="box2"></div>
      </div>
      </body>
      </html>

    3、margin左右
    margin-lefta:uto     偏右
    margin-right:auto       偏左
    margin:auto      水平居中
     
        
  • 相关阅读:
    mybatis的mapper特殊字符转移以及动态SQL条件查询
    MySQL查询结果集字符串操作之多行合并与单行分割
    MySQL查询之内连接,外连接查询场景的区别与不同
    SpringBoot异步使用@Async原理及线程池配置
    SpringBoot 属性配置文件数据注入配置和yml与properties区别
    MySQL实战45讲第33讲
    Beta冲刺第1次
    Beta冲刺第5次
    Beta冲刺第4次
    Beta冲刺第3次
  • 原文地址:https://www.cnblogs.com/staven/p/4694186.html
Copyright © 2011-2022 走看看