How to space the children of a div with css?

前端 未结 8 606
-上瘾入骨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:04

    Just put a top and bottom margin of 30px on your p element:

    p { margin: 30px 0 30px 0; }
    

    Note: the above will add this margin to all your p elements. To restrict to just this one, either add an inline style attribute:

    ...

    or better use a class:

    ...

    and in css:

    p.para { margin: 30px 0 30px 0; }
    

    Btw, the notation here for margin is:

    margin: top right bottom left;
    

    Or you can individually specify top and bottom margins:

    margin-top: 30px;
    margin-bottom: 30px;
    

    So you could have a class like this:

    .bord { margin-bottom: 30px; }
    

    and add this class to every element you want to have a margin-bottom of 30px:

    ....

提交回复
热议问题