How do you float elements without a vertical gap?

后端 未结 9 1987
野的像风
野的像风 2020-11-30 16:03

I am trying to float elements left. Here is my css:

width: 320px;
float: left;
border: 1px solid #ccc;
margin-top: 10px;
margin-right: 10px;
border-radius: 5         


        
9条回答
  •  天命终不由人
    2020-11-30 16:23

    Have two different div IDs, one could be #left and the other #right. Everything you want floated on the left side should go into #left and everything you right on the right side goes into #right.

    Then you want to add the following style:

    #left {
      float: left;
    }
    

    That should do the trick. You'll want to apply the style of the boxes separately. If you want an example of this solution in action you can check out my blog, http://refact.io and view the source of my "Recommended Services" which has a similar layout to what you are looking for (two columns with multiple items in each column).

    Let me know if this works for you.

提交回复
热议问题