如何使div *不*展开填充它的父? [英] How can I make a div *not* expand to fill it's parent?
本文介绍了如何使div *不*展开填充它的父?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个围绕图像的div,像这样:
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>
现在,我期待 image-wrapper
采取图像的大小,没有更多。但它不;而是填充到 contains-div
的高度。 (请参阅此处的实际页面: http://holyworlds.org/new_hw/wallpapers.php )
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 )
我的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,
Now, it works just fine if I don't have a Doctype declared. But everything I've tried fails if I do.
如何让 image-wrapper
的大小该图像仍然使用<!doctype html>
?
How can I make image-wrapper
be the size of the image while still using <!doctype html>
?
推荐答案
您尝试过:
.image-wrapper {
display: inline;
}
或:
.image-wrapper {
display: inline-block;
}
或:
.image-wrapper {
float: left;
}
这篇关于如何使div *不*展开填充它的父?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文