4 回答
TA贡献1790条经验 获得超9个赞
div
block
inline
inline
方法1-从标记中删除空白
例1
<div>text</div><!-- --><div>text</div><!-- --><div>text</div><!-- --><div>text</div><!-- --><div>text</div>
例2
<div>text</div><div>text</div><div>text</div><div>text</div><div>text</div>
例3
<div>text</div ><div>text</div ><div>text</div ><div>text</div ><div>text</div>
例4
<div>text </div><div>text </div><div>text </div><div>text </div><div>text </div>
方法2-重置 font-size
inline
font-size
font-size
0
font-size: 0
font-size
#parent { font-size: 0; } #child { font-size: 16px; }
font-size
em
inline
方法3-将父元素设置为 display: flex
display
flex
. (例如)
.parent { display: flex; } .parent > div { display: inline-block; padding: 1em; border: 2px solid #f00; }
.parent {
display: flex;
}
.parent > div {
display: inline-block;
padding: 1em;
border: 2px solid #f00;
}
<div class="parent">
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
<div>text</div>
</div>
双方注意到:
inline
TA贡献1895条经验 获得超7个赞
inline-block
font-size
TA贡献1854条经验 获得超8个赞
inline-block
white-space
HTML
white-space
float
float: left;
id
id
HTML
class
.container { display: inline-block; position: relative; background: rgb(255, 100, 0); margin: 0; width: 40%; height: 100px; float: left;}
TA贡献1719条经验 获得超6个赞
.container { display:block; position:relative; height:150px; width:1024px; margin:0 auto; padding:0px; border:0px; background:#ececec; margin-bottom:10px; text-align:justify; box-sizing:border-box; white-space:nowrap; font-size:0pt; letter-spacing:-1em;}.cols { display:inline-block; position:relative; width:32%; height:100%; margin:0 auto; margin-right:2%; border:0px; background:lightgreen; box-sizing:border-box; padding:10px; font-size:10pt; letter-spacing:normal;}.cols:last-child { margin-right:0;}
- 4 回答
- 0 关注
- 606 浏览
相关问题推荐
添加回答
举报