rjcarr
rjcarr

Reputation: 2091

Why is there spacing between my elements? ... and other CSS questions

I've created a fiddle that's almost what I'm looking for, but still unsure of a couple things:

http://jsfiddle.net/LrAd3/

Here are the things I'm not understanding:

vertical-align: top;

directly on the image. (EDIT: I've found more info on this and I believe I'm using it correctly.)

Thanks for taking a look. And any suggestions of improvements would be appreciated.

EDIT: I believe all my questions are answered now. Thanks for the help!

Upvotes: 2

Views: 109

Answers (2)

Yair
Yair

Reputation: 192

Another solution (although AndyM's answer above is perfectly fine) to the white-space issue with the vertical align would be to set the containing div's font-size to 0px. This will eliminate white space between the inline elements. You will, of course, need to set a different (positive) font-size for the child elements.

Upvotes: 1

Kelderic
Kelderic

Reputation: 6697

For the small space between, it's because they are set to inline-block, as someone mentioned in the comments. If you remove the physical space in the HTML code, you'll be good. Alternatively, you can make them both display:block and float:left, but you'll need to use a clearfix after them.

The different height part is harder to find, but I tracked it down. The problem child here is the box-sizing attribute. div has a default value for this of content-box. select's default value is border-box. You'll need three values though, to cover all browsers.

This fixes it:

select {
    -moz-box-sizing:content-box;
    -webkit-box-sizing:content-box;
    box-sizing:content-box;
}

Working Fiddle

Screenshot:

enter image description here

Upvotes: 1

Related Questions