背景无法工作的100%身高(尽管HTML和身高100%) [英] 100% height for background not working (despite html and body height 100%)

查看:58
本文介绍了背景无法工作的100%身高(尽管HTML和身高100%)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将我的包装设置为100%高度。但我无法做到这一点,尽管设置高度为100%。



目前,我的main_wrapper是空的。它应该给我一个红色的背景颜色。



我的目标是使用固定的底部有一个页脚,但这是脱离主题。但是,如果有人能够给予固定头寸的链接,这将是一件好事。



 < HTML> 
< head runat =server>

< / head>
< body class =body>
< form id =form1runat =server>
< div id =main_wrapper>


< / div>

< div class =clear>< / div>

< / form>

< / body>
< / html>



* {
margin:0;填充:0;
border:none;
box-sizing:border-box;
-moz-box-sizing:border-box; / * Firefox * /
-webkit-box-sizing:border-box; / * Safari * /
}

.clear {
clear:both;
}

html {
margin:0;
宽度:100%;
身高:100%;
/ * min-width:640px; min-height:480px; * /
}

body {
margin:0; / *顶部和底部0,左和右自动* /
宽度:100%;
身高:100%;
}

.body #main_wrapper {
margin:0;
宽度:100%;
身高:100%;
背景:#f00;
}


解决方案

 #form1 #main_wrapper {
margin:0;
宽度:100%;
身高:100%;
背景:#f00;
min-width:640px;
min-height:480px;
}


I want to set my wrapper to be 100% height. But I am unable to do so despite setting the height to 100%.

Currently, My main_wrapper is empty. It should give me a background color of red.

My aim is to have a footer at the bottom using fixed but that is off topic. But it will be good if someone could give a link for position fixed.

<html>
<head runat="server">

</head>
<body class="body">
    <form id="form1" runat="server">
        <div id="main_wrapper">


        </div>

        <div class="clear"></div>

    </form>

</body>
</html>



* {
    margin: 0; padding: 0;
    border: none;
    box-sizing: border-box;
    -moz-box-sizing: border-box; /* Firefox */
    -webkit-box-sizing: border-box; /* Safari */
}

.clear {
    clear: both;
}

html {
    margin: 0;
    width: 100%;
    height: 100%;
   /* min-width: 640px; min-height: 480px;*/
}

body {
    margin: 0; /*Top and Bottom 0, Left and Right auto */
    width: 100%;
    height: 100%;
}

    .body #main_wrapper {
        margin: 0;
        width: 100%;
        height: 100%;
        backgroud: #f00;
}

解决方案

    #form1 #main_wrapper {
            margin: 0;
            width: 100%;
            height: 100%;
            background:#f00;
            min-width: 640px; 
       min-height: 480px;
}

这篇关于背景无法工作的100%身高(尽管HTML和身高100%)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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