remove space between paragraph and unordered list

前端 未结 8 2148
情歌与酒
情歌与酒 2021-01-01 10:17

Text

  • One

Text 2

How do i remove the vertical space between par

相关标签:
8条回答
  • 2021-01-01 11:03

    I got pretty good results with my HTML mailing list by using the following:

    p { margin-bottom: 0; }
    ul { margin-top: 0; }
    

    This does not reset all margin values but only those that create such a gap before ordered list, and still doesn't assume anything about default margin values.

    0 讨论(0)
  • 2021-01-01 11:04

    You can use CSS selectors in a way similar to the following:

    p + ul {
        margin-top: -10px;
    }
    

    This could be helpful because p + ul means select any <ul> element after a <p> element.

    You'll have to adapt this to how much padding or margin you have on your <p> tags generally.

    Original answer to original question:

    p, ul {
        padding: 0;
        margin: 0;
    }
    

    That will take any EXTRA white space away.

    p, ul {
        display: inline;
    }
    

    That will make all the elements inline instead of blocks. (So, for instance, the <p> won't cause a line break before and after it.)

    0 讨论(0)
提交回复
热议问题