Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a div *not* expand to fill it's parent?

Tags:

html

css

layout

I have a div wrapped around an image, like this:

<div class="containing-div">
      <div class="image-wrapper">
           <img src="image.jpg">
      </div>
      <div class="unrelated-stuff">
           Blah blah blah.
      </div>
</div>

Now, I expect image-wrapper to take the size of the image, and no more. But it doesn't; it instead fills to the height of containing-div. (See actual page here: http://holyworlds.org/new_hw/wallpapers.php )

My CSS is:

.image-wrapper{
  float: left;
  box-shadow: inset 0px 4px 10px black;
  background-image: url('image.jpg');
}

.image-wrapper img{
  visibility: hidden;
}
.unrelated-stuff{
  float: left;
}

Now, it works just fine if I don't have a Doctype declared. But everything I've tried fails if I do.

How can I make image-wrapper be the size of the image while still using <!doctype html>?

like image 739
dieki Avatar asked Jun 04 '11 18:06

dieki


1 Answers

Have you tried:

.image-wrapper {
  display: inline;
}

Or:

.image-wrapper {
  display: inline-block;
}

Or:

.image-wrapper {
  float: left;
}
like image 132
Jits Avatar answered Oct 24 '22 01:10

Jits