因此,我终于学习了更多的CSS方法,并遇到了一个小问题。我有一个容器div,里面有几个div,其中一个是文本(可以是随机高度)和一个MAX高度为200px的图片。自动调整高度和嵌套div的小CSS问题
我在他们后面使用了虚线/彩色背景,需要自动展开到最高的文字或图像的高度。现在,当我使用高度:自动对容器div它适用于随机高度文本的完美:Example Screenshot
但它只是根据文本的高度进行调整;如果图像比文字高,则图像会溢出背景虚线/彩色框的底部。 Example Screenshot
我使用的是目前CSS是这样的:
h1 div#like_detailed {
margin: 0;
font-size: 1.1em;
width: 700px;
}
#details-image img {
border: none;
clear: left;
float: right;
margin: -45px 0 0 0;
max-height: 200px;
padding: 0 7px 0 10px;
}
#deets-container {
background-color: #FEF;
border: #190AE7 1px dotted;
height: auto;
margin-top: 0;
margin-bottom: 30px;
padding-top: 10px;
padding-right: 10px;
padding-left: 10px;
padding-bottom: 0;
}
并为它的HTML是这样的:
<div id="deets-container" class="rounded">
<!-- Button -->
<div class="likebtnframe">(some code)</div>
<!-- Button -->
<div class="tweetbtnframe">(some code)</div>
<!-- Button -->
<ul id="share">
<li><a name="share">(some code)</a></li>
</ul>
<!-- Submitted By -->
<div class="submitter_detailed"><span class="submitter-color smalltext">(some code)</span> (some code)</div>
<!-- Image -->
<div id="**details-image**">(some code)</div>
<!-- Like/Quote -->
<h1 id="**like_detailed**">(some code)</h1>
</div>
我有一种感觉,这是很容易的,但我跑花时间自行整理。
有人吗?
这奏效了!太感谢了! – 2011-03-12 23:22:01
没问题,祝你好运! – daryl 2011-03-13 02:01:16