How to add vertical spacing between block elements, but not top and bottom

前端 未结 5 735
余生分开走
余生分开走 2021-02-02 13:51

Say I have a bunch of P, LI, or DIV elements, with nothing between them. I want to control the vertical spacing between them, so they don\'t fit so tightly. But I don\'t want

5条回答
  •  悲哀的现实
    2021-02-02 14:28

    You can use adjacent selectors. You can define like this:

    p + p{
     margin-top:0;
    }
    

    OR

    p ~ p{
     margin-top:0;
    }
    

提交回复
热议问题