Embedded padding/margin in fonts

后端 未结 16 971
执念已碎
执念已碎 2021-01-08 00:56

It seems that all fonts have some sort of embedded padding or margin. By setting:

margin: 0px;
padding: 0px;

You never get what you want. D

16条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-08 01:23

    I have run into this pain a couple of times when using some webfonts for icons and gained better control by placing them in an absolute positioned container.

    HTML

     

    CSS

     .relative { position:relative; }
     .webfont {  position: absolute;
    
                 top: -5px; 
                 left: -5px; /* easier control with these values */
               }
    

    This felt like a better way to control things cross browser, rather than say, using positive/negative margins and paddings.

    Giving the text block a container and class we have much more cleaner ability to tweak it's position cross browser. ( IMO ).

    Might be something there.

    Cheers,

    Rob

提交回复
热议问题