How to space the children of a div with css?

前端 未结 8 611
-上瘾入骨i
-上瘾入骨i 2021-02-03 17:37

I want a gap of say 30px; between all children of my div. E.g if I have:

...

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-03 18:21

    You can easily do that with:

    #parent > * + * {
      margin-top: 30px;
    }
    

    This will be applied to all direct children except the first one, so you can think of it as a gap between elements.

提交回复
热议问题