-webkit-margin adds unwanted margin on texts

前端 未结 12 1775
不思量自难忘°
不思量自难忘° 2020-11-29 02:32

This hadn\'t hit me until now (and this is not only in webkit browsers). On all texts in like p tags, h1 tags etc... there\'s an extra space over a

12条回答
  •  天涯浪人
    2020-11-29 02:54

    For me, the picture was:

    * {margin:0;padding:0;}
    

    Firefox (FF) and Google Chrome both put 0.67em margins regardless. FF showed its default margin, but crossed out, but applied it anyway. GC showed its default margin (-webkit-margin-before...) uncrossed.

    I applied

    * {margin:0;padding:0; -webkit-margin-before: 0; -webkit-margin-after: 0;}
    

    but to no avail, although GC now showed its default margin crossed.

    I found out, that I can apply either

    line-height: 0;
    

    or

    font-size: 0;
    

    to achieve the desired effect. This makes sense, if one assumes, that the margin is of the .67em - type. If anybody could give an explanation, why browsers make our lives miserable by applying a line-height dependent, non-removable margin, i would be really grateful.

提交回复
热议问题