css – 如何使div高度填充可用空间

前端之家收集整理的这篇文章主要介绍了css – 如何使div高度填充可用空间前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个3列布局,列下面有一些细节.

你会注意到一列的高度大于其他的高度.我想让其他两个div自动填充剩余的空间(直到蓝色div).文本将被动态加载,所以我需要这个工作与任何列更大(和任意数量).

这可以用HTML / CSS来完成,还是使用一些JavaScript

HTML代码(相关部分):

<div id="content">

    <div id="iconsHolder">

        <div id="info">
            <div id="info_content">
                <p><?PHP echo img('images/man.png'); ?></p>
                <h2>Some guy over here</h2>
                <p class="light justify">It doesn't matter what is being said at the moment. Nothing is said here.</p>
            </div>
        </div>

        <div id="comp">
            <div id="comp_content">
                <p><?PHP echo img('images/computer.png'); ?></p>
                <h2>Computer Development</h2>
                <p class="light justify">Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,consectetur,adipisci velit... Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,adipisci velit...</p>
            </div>
        </div>

        <div id="story">
            <div id="story_content">
                <p><?PHP echo img('images/library.png'); ?></p>
                <h2>Story telling</h2>
                <p class="light justify">This is another short story.</p>
            </div>
        </div>
    </div>
    <div id="details">
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries,but also the leap into electronic typesetting,remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>

</div>

CSS代码(相关部分):

#content {
    width: 60em;
    margin: 0px auto;
}

#info,#comp,#story {
    width: 18em;
    float: left;
    padding-left: 1em;
    padding-right: 1em;
    padding-top: 2em;
    background-color: #DDD;
    height: 100%;
}

#info_content,#comp_content,#story_content {
    text-align: center;
}

#details {
    clear: both;
    background-color: #EEF;
    padding: 1em;
}

解决方法

CSS解决方案是使用背景颜色对外部容器进行风格化,这被称为假(虚拟)bakcground.

喜欢这个:

#iconsHolder {
    background-color: #DDD;
}

这种方法(至少在这种情况下)保证所有的背景是一样的.

原文链接:https://www.f2er.com/css/214647.html

猜你在找的CSS相关文章