Heim > Artikel > Web-Frontend > Problem mit Leerzeichen im Inline-Block
1. Problem
Wenn das Element das Inline-Block-Attribut hat, gibt es eine leere Lücke
2. Lösung
1
1) Entfernen Sie die Lücken zwischen den Elementen
<span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="space"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">a </span><span style="color: #ff0000">href</span><span style="color: #0000ff">="##"</span><span style="color: #0000ff">>A</span><span style="color: #0000ff"></</span><span style="color: #800000">a </span><span style="color: #0000ff">><</span><span style="color: #800000">a </span><span style="color: #ff0000">href</span><span style="color: #0000ff">="##"</span><span style="color: #0000ff">><font color="#000000">B</font></span><span style="color: #0000ff"></</span><span style="color: #800000">a </span><span style="color: #0000ff">><</span><span style="color: #800000">a </span><span style="color: #ff0000">href</span><span style="color: #0000ff">="##"</span><span style="color: #0000ff">><font color="#000000">C</font></span><span style="color: #0000ff"></</span><span style="color: #800000">a</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span>
weg
<span style="color: #0000ff"><</span><span style="color: #800000">div </span><span style="color: #ff0000">class</span><span style="color: #0000ff">="space"</span><span style="color: #0000ff">></span> <span style="color: #0000ff"><</span><span style="color: #800000">a </span><span style="color: #ff0000">href</span><span style="color: #0000ff">="##"</span><span style="color: #0000ff">><font color="#000000">A</font></span><span style="color: #000000"> </span><span style="color: #0000ff"><</span><span style="color: #800000">a </span><span style="color: #ff0000">href</span><span style="color: #0000ff">="##"</span><span style="color: #0000ff">><font color="#000000">B</font></span><span style="color: #000000"> </span><span style="color: #0000ff"><</span><span style="color: #800000">a </span><span style="color: #ff0000">href</span><span style="color: #0000ff">="##"</span><span style="color: #0000ff">><font color="#000000">C</font></span><span style="color: #0000ff"></</span><span style="color: #800000">a</span><span style="color: #0000ff">></span> <span style="color: #0000ff"></</span><span style="color: #800000">div</span><span style="color: #0000ff">></span>
1. Verwenden Sie negative Randwerte (Rand-Rechts-Werte können in verschiedenen Browsern unterschiedlich sein)
<span style="color: #800000">.space a </span>{<span style="color: #ff0000"> display</span>:<span style="color: #0000ff"> inline-block</span>;<span style="color: #ff0000"> margin-right</span>:<span style="color: #0000ff"> -3px</span>; }
<span style="color: #800000">.space </span>{<span style="color: #ff0000"> font-size</span>:<span style="color: #0000ff"> 0</span>;
}<span style="color: #800000"> .space a </span>{<span style="color: #ff0000"> font-size</span>:<span style="color: #0000ff"> 12px</span>; }
<span style="color: #800000">.space </span>{<span style="color: #ff0000"> letter-spacing</span>:<span style="color: #0000ff"> -3px</span>; }<span style="color: #800000"> .space a </span>{<span style="color: #ff0000"> letter-spacing</span>:<span style="color: #0000ff"> 0</span>; }
<span style="color: #800000">.space </span>{<span style="color: #ff0000"> display:inline-table;(为了兼容Chrome)</span>
<span style="color: #ff0000"> word-spacing</span>:<span style="color: #0000ff"> -6px</span>; }<span style="color: #800000"> .space a </span>{<span style="color: #ff0000"> word-spacing</span>:<span style="color: #0000ff"> 0</span>; }
Inline-Block und Baseline
https://segmentfault.com/a/1190000002668492