tags:

views:

928

answers:

3

I am using this css to format two columns but I am still getting margin space between two. I can eliminate it with use of margin-left: -4px; or some such. Is there a more elegant way to do this or is there something wrong with the CSS code?

div.col1{
  display: inline-block;
  min-height: 900px;
  height: 100%;
  width 300px;
  margin: 0px;
  background-color: #272727;
  overflow: hidden;
  border: 1px dotted red;
}

div.col2{
  display: inline-block;
  min-height: 900px;
  height: 100%;

  width: 620px;
  margin: 0px;

  vertical-align: top;
  border: 1px dotted red;
  overflow: hidden;
}
A: 

You should also specify:

padding: 0;
Dmytrii Nagirniak
yes, i have dotted red borders showing the element's locations. I've tried firebug, but it does not attribute spacing to any element style.
Pavel Zaitsev
+3  A: 

Perhaps you have:

<div class="col1">
    Stuff 1
</div>
<div class="col2">
    Stuff 2
</div>

? If so then this is probably a whitespace problem (it turns out whitespace does matter in html). This should fix it:

<div class="col1">
    Stuff 1
</div><div class="col2">
    Stuff 2
</div>
Caleb
That is so silly, thanks it worked!
Pavel Zaitsev
To be more precise - it matters here because the blocks are treated as inline (due to inline-block)
K Prime
Nice catch! I wouldn't easily find it.
Dmytrii Nagirniak
A: 

apply float:left and that will remove the space so the text doesn't have to be on 1 line.

Evan