Inline blocks: exploring their spatial properties
P粉360266095
2023-08-22 19:42:53
<p>There is a strange gap between inline blocks. I can live with it until I load more content with an AJAX call and this little gap disappears. I know I'm missing something here. </p>
<pre class="brush:php;toolbar:false;">div {
width: 100px;
height: auto;
border: 1px solid red;
outline: 1px solid blue;
margin: 0;
padding: 0;
display: inline-block;
}</pre>
<p>http://jsfiddle.net/AWMMT/</p>
<p>How can I make the spacing between inline blocks consistent? </p>
http://jsfiddle.net/AWMMT/1/
Your spaces are line breaks that the browser converts into "spaces" when displayed.
Or you could try using CSS to make some small adjustments:
A flexbox will conveniently ignore spaces between its child elements and will be displayed like a continuous inline-block element.
http://jsfiddle.net/AWMMT/470/
Spaces in HTML. There are several possible solutions. From best to worst:
float: left
instead ofdisplay: inline-block
, but this will have a bad effect on the height: http://jsfiddle.net/AWMMT/3 /font-size
of the container to 0 and the appropriatefont-size
for the inner elements: http://jsfiddle.net/AWMMT/4 / - This is very simple, but you can't take advantage of relative font size rules (percentage, em) on inner elements