72上下两行布局

1、上下两行布局=>正好占满全屏=>方法一:用calc。内容超长,会出现滚动条,不会超屏。
```html:run
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
padding: 0;
margin: 0;
}

html, body {
height: 100%;
}

.nav {
height: 50px;
background: #BBE8F2;
width: 100%;
}

.body {
height: calc(100% - 60px);
background: #D9C666;
margin-top: 10px;
font-size: 0;
}

.inline {
display: inline-block;
}

.left {
width: 200px;
height: 100%;
overflow: auto;
background: palevioletred;
margin-right: 10px;
font-size: 16px;
}

.right {
width: calc(100% - 210px);
height: 100%;
overflow: auto;
background: rebeccapurple;
font-size: 16px;
}
</style>
</head>
<body>
<div class="nav"></div>
<div class="body">
<div class="inline left">
</div>
<div class="inline right">
</div>
</div>
</body>
</html>
```

2、上下两行布局=>正好占满全屏=>方法二:用flex。内容超长,不会出现滚动条,会超屏。
```html:run
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
padding: 0;
margin: 0;
}

html, body {
height: 100%;
}

.full {
display: flex;
flex-direction: column;
}

.nav {
height: 50px;
background: #BBE8F2;
width: 100%;
}

.body {
flex: 1;
background: #D9C666;
font-size: 0;
}

.inline {
display: inline-block;
}

.left {
width: 200px;
height: 100%;
overflow: auto;
background: rebeccapurple;
font-size: 16px;
margin-right: 10px;
}

.right {
width: calc(100% - 210px);
height: 100%;
overflow: auto;
background: rebeccapurple;
font-size: 16px;
}
</style>
</head>
<body class="full">
<div class="nav"></div>
<div class="body">
<div class="inline left">
</div>
<div class="inline right">
</div>
</div>
</body>
</html>
```
3、上下两行布局=>下行用最小高度=>方法一:用min-height。内容超长,会出现滚动条,不会超屏。
```html:run
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>最小高度</title>
<style>
*{
padding: 0;
margin: 0;
}
.nav {
height: 50px;
background: #BBE8F2;
}
.body {
min-height: 500px;
background: #D9C666;
}
p{
height:100px;
}
</style>
</head>
<body>
<div class="nav"></div>
<div class="body"></div>
</body>
</html>
```
4、上下两行布局=>总高度不变,此增彼减=>方法一:用flex。内容超长,不会出现滚动条,会超屏。
```html:run
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
* {
margin: 0;
padding: 0;
}
.full {
height: 600px;
background: red;
display: flex;
flex-direction: column;
}
.up {
background: blue;
}
.down {
background: green;
flex: 1; /*height:100%;*/
}
</style>
</head>
<body>
<div class="full">
<div class="up">
<p>ABCD</p>
</div>
<div class="down">
<p>DCBA</p>
</div>
</div>
</body>
</html>
```

转载于:https://www.cnblogs.com/gushixianqiancheng/p/10967029.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值