kkh
kkh

Reputation: 4869

Divs with display inline-block

I have two similar divs which are beside each other. But there is white space in between which I cannot remove?

My html as below

<div class="model-box" style="background-color:red;display:inline-block;width:98px;height:30px;">   
</div>
<div class="model-box" style="background-color:red;display:inline-block;width:98px;height:30px;">   
</div>

the fiddle as below

http://jsfiddle.net/xJW7G/

Why is this so?

Thanks in advance for the help?

Upvotes: 0

Views: 99

Answers (3)

Mark Rhodes
Mark Rhodes

Reputation: 10217

It's because of the white-space character in between the divs, you could just get rid of it, see: http://jsfiddle.net/xJW7G/1/, or comment it out e.g.

<div class="model-box" style="background-color:red;display:inline-block;width:98px;height:30px;">   
</div><!--
--><div class="model-box" style="background-color:red;display:inline-block;width:98px;height:30px;">   
</div>

Upvotes: 2

Itay Gal
Itay Gal

Reputation: 10834

Yuo might want to use float: left; instead of display: inline;

DEMO

Upvotes: 0

Florin
Florin

Reputation: 6169

Add this css style to your seccond div

margin:0 0 0 -6px;

jsFiddle

Upvotes: -1

Related Questions