如果要实现2列固定宽度,以及居中。
摘自狂人:浮动(float)是css布局中的非常强大的布局功能,也是理解css的关系问题所在,css中,包括div中的任何元素都可以以浮动的方式进行。看2行代码:
<div style="width: 50%; height: 100px; margin: 100px auto; background: red;">
        </div>
        <div style="width: 40%; height: 100px; margin: 100px auto; background: green;">
        </div>


如何将这2个div并列在一起呢?只要设置2个div的浮动为向左浮动就可以了。
<div style="width: 50%; height: 100px; margin: 100px auto; background: red;float:left;">
        </div>
        <div style="width: 40%; height: 100px; margin: 100px auto; background: green;float:left;">
        </div>

 


















相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2022-03-06
  • 2022-12-23
  • 2022-01-07
猜你喜欢
  • 2021-09-05
  • 2021-10-14
  • 2021-07-07
  • 2021-11-03
  • 2021-07-05
  • 2021-09-26
  • 2021-10-17
相关资源
相似解决方案