使用Float

<!--已知两个div的宽度使用[Float]使两个DIV同行!注:float使用后需要清除;所以多写一个div-->
    <div style="width: 300px; height: 200px; border: 1px solid #4cff00;">
        <div style="width: 70%; height: 50%; float: left; background-color: red;">我是第一个div</div>
        <div style="width: 30%; height: 50%; float: right; background-color: yellow;">我是第二个div</div>
        <div style="clear: both;"></div>
    </div>

网页效果:

div不换行_div同行_div强制不换行

 

相关文章:

  • 2021-12-06
  • 2022-12-23
猜你喜欢
  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-26
  • 2022-01-07
  • 2021-08-11
相关资源
相似解决方案