身体及其子元素的100%高度 [英] 100% height for body and its child elements

查看:133
本文介绍了身体及其子元素的100%高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为 body 指定一个背景颜色,它只显示一定距离。我需要它是全高度和其子元素。其中一个子元素具有 border-right ,它也需要在全屏高度上显示。



看起来像(示例一)更好地检查我的演示





以及固定标题的版本 - http://jsfiddle.net/WAJtk/1/



您可能也喜欢这支笔 - http://codepen.io/lukeocom/pen/KqAfG


I am specifying a background color for the body which displays up to a certain distance only. I need it to be full height and for its child elements too. One of its child elements has border-right which also needs to show over the full screen height.

My CSS looks like(sample one) better check my demo

demo page

   html,body {
         height: 100%; 
         background-color: #fefefe;
    }
    .cover {
         height: 100%;
    }
    .left_side {
        float: left; 
        height: 100%;
        border-left: 1px solid #ccc;
        width: 31%;  
    } 

and html is

     <body>
         <div class="cover">
            <div class="left_side">
            </div>
         </div>
      </body>

and the bgcolor and childs border seems up-to some limited distance only like what is that problem guys i need that background and border as 100% height.

解决方案

Remove height:100% from your body and html style.

Instead of having a border set to the left container, try setting the border on the content container instead.

your css would be something like:

.large-9 .columns .right_side{border-left:1px solid #333;}

the left column is currently set to 100% and renders correctly. the problem is that it doesnt take into account the overflow content you cannot see, until you scroll. The other solution would be to absolute or fixed position the left container, and set its top and bottom values to 0.

css for that would be something like:

.left_side .full_height{position:fixed;top:0;bottom:0;width:200px;}

Here's a really basic layout with a fixed left column - http://jsfiddle.net/WAJtk/

and a version with a fixed header too - http://jsfiddle.net/WAJtk/1/

you might also like this pen - http://codepen.io/lukeocom/pen/KqAfG

这篇关于身体及其子元素的100%高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆