1

I want to to display two divs inline, one div is 25% and the other 75%, when I use:

display: inline-block; 

It seems to generate gaps in between the two divs, which obviously knocks the 75% div down.

How do I remove the gap? I used:

vertical-align: top; 

This has removed the top gap... Now just the side gap needs to go.

See here jsfiddle.

Steven_Harris_
  • 1,071
  • 1
  • 11
  • 22

6 Answers6

7

The problem is that you have a white space between your two div elements, and because they are of inline-block display, it renders just like a space between two letters in a regular text.

The solution is using a negative word-spacing on the container:

word-spacing: -1em;

jsFiddle Demo


See more here: Fighting the Space Between Inline Block Elements

Also here display: inline-block extra margin

Community
  • 1
  • 1
Itay
  • 16,601
  • 2
  • 51
  • 72
1

It's because of the whitespace between your divs in the HTML.. Make it like this:

<div class="grid_one">

</div><div class="grid_two">

</div>

http://jsfiddle.net/npP3p/1/

Or, use float:left;, but remember to clear the floating after that or give the container a height..

Tim Baas
  • 6,035
  • 5
  • 45
  • 72
0

Just add float:left; to first class.

Fiddle

majorhavoc
  • 2,385
  • 1
  • 24
  • 26
0

Tim is correct, its the whitespace that creates the margin.

Another solution to it is to add a margin-right: -4px to .grid_one, check the updated fiddle.

GreyRoofPigeon
  • 17,833
  • 4
  • 36
  • 59
-1

Float left was the precious gem you were missing

Float:left;

http://jsfiddle.net/npP3p/2/

srijan
  • 1,504
  • 1
  • 13
  • 24
-1

Why not float: left; the divs?

kunalbhat
  • 1,709
  • 10
  • 11