我有一個div圖像周圍包裹着,就像這樣:如何創建一個div *而不是*展開以填充它的父項?
<div class="containing-div">
<div class="image-wrapper">
<img src="image.jpg">
</div>
<div class="unrelated-stuff">
Blah blah blah.
</div>
</div>
現在,我希望image-wrapper
取圖像的大小,並沒有更多的。但它不;它反而填充到containing-div
的高度。 (見實際頁面在這裏:http://holyworlds.org/new_hw/wallpapers.php)
我的CSS是:
.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;
}
現在,如果我沒有做一個DOCTYPE聲明的工作就好了。但是我所做的一切都失敗了。
如何使image-wrapper
成爲圖像的大小,同時仍然使用<!doctype html>
?
是的,但他們都沒有工作。 – snostorm 2011-06-04 18:51:01
float在這裏並不是最好的選擇...... inline(-block)更合適。 – 2011-06-04 18:51:48
更正;所有這些工作。他們修復它的寬度,但由於某種原因,它不是高度。看看頁面,它有浮動:留在。 :) – snostorm 2011-06-04 19:07:19