How to reduce the space between

tags?

后端 未结 13 1476
生来不讨喜
生来不讨喜 2021-02-04 23:26

I have a page that I\'m converting to PDF. This page contains a number of paragraphs and they don\'t all fit onto a single page. If I could reduce the spacing between the

相关标签:
13条回答
  • 2021-02-04 23:45

    Setting both margin-bottom and margin-top to 0em will remove a space between paragraphs:

    <style type="text/css">
    p {margin-bottom: 0em; margin-top: 0em;}
    </style>
    
    0 讨论(0)
  • 2021-02-04 23:47

    I'll suggest to set padding and margin to 0.

    If this does not solve your problem you can try playing with line-height even if not reccomended.

    0 讨论(0)
  • 2021-02-04 23:52

    Try

    margin: 0;
    padding: 0;
    

    If this doesn't work, try

    line-height: normal;
    
    0 讨论(0)
  • 2021-02-04 23:58

    A more real-world example:

    p { margin: 10px 0;}
    
    0 讨论(0)
  • 2021-02-05 00:00

    If you're converting an HTML doc into a PDF page, but the page spills onto two pages, try reducing the font size. Of course you can also decrease the spacing between paragraphs (with the CSS margin-top/margin-bottom styles), or even the left and right gutters with margins. But to my eye, keep things in proportion and just make the text a little smaller:

    p { font-size: 90%; }
    

    or

    body { font-size: 9.5pt }
    
    0 讨论(0)
  • 2021-02-05 00:01
    <style type="text/css">
     p {margin-bottom: -1em;  margin-top: 0em;} 
    </style>
    

    This completely worked for me. Paragraphs were right below each other. When I used 0em for both the margins, there was still some space left in between the lines. I went for Developer tools in my browser, tried with -1em and it worked.

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