微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

几个布局

一、三行布局

1、老办法
不管你是用calc还是直接写,本质都是固定定位
Css部分

<span style="font-family:Microsoft YaHei;"><style>
html,body{
	margin:0;
	padding:0;
	height:100%;
	overflow:hidden;
}
#top{
	position:absolute;
	top:0;
	left:0;
	background-color:#05C020;
	height:50px;
	width:100%;
	z-index:100;
}
#bottom{
	position:absolute;
	bottom:0;
	left:0;
	background-color:#88D6E9;
	height:50px;
	width:100%;
	z-index:100;
}
	
#middle{
	position:absolute;
	width:100%;
	overflow:auto;
	background-color:#F0E6A2;	
	bottom:50px;
	top:50px;
	_height:100%;
	_border-top:50px solid #eee;
	_border-bottom:50px solid #eee;
	_top:0px;
	z-index:90;
}
#middle p{margin:0;}
</style></span>

html

<span style="font-family:Microsoft YaHei;"><body>
<div id="all">
    	<div id="top">top</div>
        <div id="middle">
        	<p>有句话说,若可安逸,谁愿奔波。确。还是趁着年轻,多年代,没有什没有别人那么好吧。</p>
        </div>
        <div id="bottom">bototm</div>   
</div>
</body></span>

2、flex
html部分

<body>
  <div class="iii">
  <div class="yyy"></div>
  <div class="ttt">sssssssssssssssssssssssssssseeeeeessssss</div>
  <div class="yyy"></div>
</div>

css部分

.iii{
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }
  .yyy {
    height: 30px;
    width: 100%;
    background-color: aqua;
    
  }

  .ttt {
    height: 30px;
    width: 100%;
    flex: 1;
    /* overflow: auto; */

  }

在这里插入图片描述


这个思想可以用于两列三列多列布局中
我举个三列的例子

<style>
  .iii{
    display: flex;
    flex-direction: row;   
  }
  .yyy {
    height: 30px;
    width: 100px;;
    background-color: aqua;
  }

  .ttt {
    height: 30px;
    flex: 1;
  }
</style>
<body>
  <div class="iii">
  <div class="yyy"></div>
  <div class="ttt">sssssssssssssssssssssssssssseeeeeessssss</div>
  <div class="yyy"></div>
</div>

在这里插入图片描述

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐