margin-right负值

来源:3-7 布局-解题-3

mike0326

2021-06-22

给 margin-right 负值为什么没有跑到 center 上边,而是跑到了 container 的 padding 位置

写回答

2回答

逃离外包

2022-04-24

 <style>

      body{

        min-width: 550px;

      }

      #header{

        text-align: center;

        background-color: #f1f1f1;

      }

      #container{

        padding-left: 200px;

        padding-right: 150px;

      }

      #center{

        background-color: #ccc;

        width:100%;

      }

      #left{

        position: relative;

        background-color: yellow;

        width: 200px;

        margin-left: -100%;

        right:200px;

      }

      #right{

        background-color: red;

        width:150px;

        margin-right: -150px;

      }

      #footer{

        clear: both;

        text-align: center;

        background-color: #f1f1f1;

      }

      #container .column{

        float: left;

      }

    </style>

  </head>

  <body>

    <div id="header">this is header</div>

   <div id="container">

      <div id="center" class="column">this is center</div>

      <div id="left" class="column">this is left</div>

      <div id="right" class="column">this is right</div>

   </div>

   <div id="footer">this is footer</div>

  </body>

//img.mukewang.com/szimg/6264d6d809b0b3a719200902.jpg

0
0

双越

2021-06-22

把相关代码贴出来吧。

0
0

一天时间高效准备前端技术一面 匹配大厂面试要求

针对时下面试高频考点,帮助新人js面试快速通关

4694 学习 · 1681 问题

查看课程