English 中文(简体)
获取“ faux” 列以覆盖父的高度
原标题:Getting "faux" column to span height of parent
  • 时间:2012-05-26 05:44:50
  •  标签:
  • html
  • css

http://jsfiddle.net/YZdv4/50/ 这里的jsfidles

我想你可以用绝对的定位和刺绣来完成这个任务, 但是,用css/floats就可以解决问题吗?

对不起, 如果这很难理解, 但是 Im 试图使紫色 bg 转向 beground:papayawhip , 使父体 100%的高度为

 <div id="container" class="cf">
    <div id="header">
        <p>im header</p>
    </div>
    <div id="content" class="cf">
        <div id="left"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce viverra enim sit amet ante lacinia iaculis. Nullam ac nulla vel purus posuere luctus. Mauris a elit nisl. Mauris commodo convallis sem in feugiat. Suspendisse mauris leo, molestie sit amet commodo eget, mollis a nibh. Suspendisse auctor commodo interdum. Aliquam posuere, erat eget pharetra hendrerit, mi tellus tristique tellus, vel accumsan elit nisi ac diam. Morbi consequat ligula est, et volutpat ante. Curabitur pulvinar nulla non neque iaculis pulvinar sed eu sapien. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce sodales metus et nisl dictum non ullamcorper magna blandit. Aliquam erat volutpat. Aenean id massa sed massa sollicitudin euismod sed non lorem. Sed accumsan, nisl vitae adipiscing cursus, magna enim accumsan augue, a rutrum mauris lorem non mauris. Sed consequat venenatis venenatis.
</P></div>
        <div id="right">
            <img src="http://vvcap.net/db/0ggWsnKKw1FI1w0xojUT.png" />
            <img src="http://vvcap.net/db/Rik9UwaQOUuhKpML16td.png" />    


        </div>                        


    </div>
    <p>im the container</p>
</div>


   div#container{background:yellow;min-height:500px;}
div#header{background:pink; height:100px;}
div#content{position:relative;background:purple; height:100%;}/*heres parent container*/

div#content #left{float:left; height:100%; background:#222; color:#fff;width:50%;}
div#content #right{float:left; height:100%; background:papayawhip;width:50%;}
div#content #right img{}
/* For modern browsers */
.cf:before,
.cf:after {
    content:"";
    display:table;
}

.cf:after {
    clear:both;
}

/* For IE 6/7 (trigger hasLayout) */
.cf {
    *zoom:1;
}

最佳回答

我不确定我确切地知道你们想要什么,但我对问题的预想导致这一结果:小提琴,http://jsfiddle.net/grE5A/62/" rel=“nofollow”>http://jsfiddle.net/grE5A/62/

我只在这里粘贴了更改的 CSS 安保部 元素 。

HTML HTML

  <div id="container" class="cf">
        <div id="header">
            <p>im header</p>
        </div>
        <div id="content" class="cf">
             <div id="right">
                <img src="http://vvcap.net/db/0ggWsnKKw1FI1w0xojUT.png" />
                <img src="http://vvcap.net/db/Rik9UwaQOUuhKpML16td.png" />    


            </div>               

            <div id="left"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce viverra enim sit amet ante lacinia iaculis. Nullam ac nulla vel purus posuere luctus. Mauris a elit nisl. Mauris commodo convallis sem in feugiat. Suspendisse mauris leo, molestie sit amet commodo eget, mollis a nibh. Suspendisse auctor commodo interdum. Aliquam posuere, erat eget pharetra hendrerit, mi tellus tristique tellus, vel accumsan elit nisi ac diam. Morbi consequat ligula est, et volutpat ante. Curabitur pulvinar nulla non neque iaculis pulvinar sed eu sapien. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Fusce sodales metus et nisl dictum non ullamcorper magna blandit. Aliquam erat volutpat. Aenean id massa sed massa sollicitudin euismod sed non lorem. Sed accumsan, nisl vitae adipiscing cursus, magna enim accumsan augue, a rutrum mauris lorem non mauris. Sed consequat venenatis venenatis.
    </P></div>



        </div>
        <p>im the container</p>
    </div>

CSS 安保部

/*heres parent container*/

div#content #left {
    float: none;
    height: 100%;
    background: #222;
    color: white;
    width: 50%;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 10;
}

div#content #right {
    float: none;
    height: 100%;
    background: 
    papayaWhip;
    width: 50%;
    position: relative;
    padding-left: 50%;
    z-index: 0;
}
问题回答

背景结尾是因为它是内容的结尾(浮标的奇数之一 ) 。 我找到的木乃伊背景填满整个紫色背景的唯一方法就是在底部加贴。 例如 padding- bottom: 25%; 或不管% 有效 。

有一个问题:

DIV#left 的孩子无法使用父 DIV s min- leight 来计算自己的身高

div#container{background:yellow;min-height:500px;}

这就是为什么它会延伸至 DIV#content 的底部。

编辑 :

我不总是建议布局的表格, 但当我做的时候,它是为这样的问题。

http://jsfiddle.net/YZdv4/56/





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签