How to display items side-by-side without using tables?

后端 未结 9 1839
野性不改
野性不改 2020-12-08 16:14

For example you want to display an image beside a text, usually I would do this:

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 16:34

    The negative margin would help a lot!

    The html DOM looks like below:

    Main content
    Left Images or something else

    And the CSS:

    .main {
      float:left;
      width:100%;
    }
    
    .main_body{
      margin-left:210px;
      height:200px;
    }
    .left{
      float:left;
      width:200px;
      height:200px;
      margin-left:-100%;
    }
    

    The main_body will responsive it's with, may it helps you!

提交回复
热议问题