为了账号安全,请及时绑定邮箱和手机立即绑定

css 布局排版问题

css 布局排版问题

kixv 2018-07-25 17:55:37
1 foot固定底部 但是子类内容高度大于100%会随着下移2 子类最小高度100% (所以body需要设置高度)3 foot和body是兄弟关系  不可以包在body里  
查看完整描述

1 回答

?
业余奶茶品鉴师

TA贡献260条经验 获得超388个赞

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    * {           
        padding: 0;           
        margin: 0;       
    }       
    .body {           
        background: green;           
        width: 100%;           
        min-height: 96%;       
    }       
    .foot {           
        background: orange;           
        width: 100%;           
        height: 4%;        
    }       
    .child {           
        width: 40%;           
        height: 1000px;           
        background: red;       
    }   
    </style>
</head>
<body>
<div class="main">
    <div class="body">
        <div class="child"></div>
    </div>
    <div class="foot"></div>
    </div>
</body>
</html>

采纳下吧

查看完整回答
1 反对 回复 2018-07-25
  • kixv
    kixv
    不符合第二条哦 子类最小高度需要100% 不是固定高度
  • 业余奶茶品鉴师
    业余奶茶品鉴师
    * { padding: 0; margin: 0; } .main { width: 200px; height: 400px; } .body { background: green; width: 100%; min-height: 96%; } .foot { background: orange; width: 100%; height: 4%; } .child { width: 40%; min-height: 100%; background: red; }
  • kixv
    kixv
    应该不对哦 body只有一个min-height没有height 所以这么写child的min-height是无效的 实际高度为0
点击展开后面3
  • 1 回答
  • 0 关注
  • 899 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信