strut 支柱

1.文本节点

html结构如下:

<div>
    <p>1</p>
    <p>2</p>
    <p>3</p>
</div>

打印出来的childNodes如下:

0 #text
1 <p>​1​</p>​
2 #text
3 <p>​2​</p>​
4 #text
5 <p>​3​</p>​
6 #text

所谓的“#text”就是标签之间的空白

html

    <div><p>1</p><p>2</p><p>3</p></div>

printout:

0 <p>​1​</p>​
1 <p>​2​</p>​
2 <p>​3​</p>​

解决办法:nodeType。

2.inline-block之间的空隙

html结构

<div class="div1">1</div><div class="div2">2</div><div class="div3">3</div><div class="div4">4</div>

效果图:

image

html结构

<div class="div1">1</div>
<div class="div2">2</div>
<div class="div3">3</div>
<div class="div4">4</div>

效果图:

image

解决办法:父容器font-size:0。

3.

image

解决办法:父容器font-size:0。

原文地址:https://www.cnblogs.com/jun3101s/p/5668278.html