block white space fix not working
I am trying to create "floating" columns using inline blocks (as I am sick of floating left with clearfix). Everywhere I read, a way to get rid of the white space with inline blocks is to use word-spacing : -4px
or negative margin of -4px. But, for me -4px is not fixing the issue. Why is that?
See tiny white space visible in Chrome at 100% browser zoom:
See random spaces at 110% zoom
My html is:
<div class="row">
<div class="col1">col 1</div>
<div class="col1">col 1</div>
<div class="col1">col 1</div>
<div class="col1">col 1</div>
<div class="col1">col 1</div>
<div class="col1">col 1</div>
</div>
CSS:
.content-wrap {word-spacing : -4px;}
.col1, .col2, .col3, .col4, .col5, .col6, .col7, .col8, .col9, .col10, .col11, .col12, .col13, .col14, .col15, .col16, .col17, .col18 {
display: inline-block;
vertical-align: top;
background-color:#eee;
padding:0;
margin:0;
}
.col9 {width: 50%;}
EDITED : Potential solutions: -5px fixes, but I am not sure what new issues that would introduce.
Inline-block: whitespace surrounding inline-block elements becomes relevant, it behaves just like text.
I suggest three solutions to overcome this issue(probably there are more):
1)Solution using float: left
instead of display: inline-block
.content-wrap {
word-spacing: -4px;
}
.col1,
.col2,
.col3,
.col4,
.col5,
.col6,
.col7,
.col8,
.col9,
.col10,
.col11,
.col12,
.col13,
.col14,
.col15,
.col16,
.col17,
.col18 {
display: inline-block;
vertical-align: top;
background-color: #eee;
padding: 0;
margin: 0;
font-size: 16px;
}
.col9 {
width: 50%;
}
.row{
font-size: 0;
}
<div class="row">
<div class="col1">col 1</div>
<div class="col1">col 1</div>
<div class="col1">col 1</div>
<div class="col1">col 1</div>
<div class="col1">col 1</div>
<div class="col1">col 1</div>
</div>
只需使用float就可以了,你也可以清理你的css并像这样选择以'col'开头的所有列。
div[class^='col'],div[class*='col']{
float: left;
vertical-align: top;
background-color: #eee;
padding:0;
margin:0;
}
链接地址: http://www.djcxy.com/p/89304.html
上一篇: 图中img和figcaption之间的不需要的空间
下一篇: 阻止白色空间修复无效