移动端结构上下固心猿意马中心自顺应,本家儿要运用的css为flex。
经由过程flex的属性flex:1; 实现中心区域拉伸,获得自顺应结果。
东西/原料
- 代码编纂器
- html、css(本家儿如果flex)
方式/步调
- 1
第一步:界说本家儿体布局
界说一个div中包含三个小div
年夜div样式:
display: flex;
flex-direction:column;
- 2
第二步:上下固心猿意马
顶部与底部样式 固心猿意马定位 position:fixed;
顶部top: 0px;
底部bottom: 0px;
- 3
第三步:中心自顺应
中心自顺应区域样式
flex:1;
overflow: scroll;
- 4
第四步:要在样式表中添加 html,body{height:100%;}
原因:让中心区域有个高度可以担当
- 5
第五步:完整代码
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>百度经验</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
html,body{height:100%;}
body{
font-family: 微软雅黑;
background-color: #f4f4f4;
}
.demon{
display: flex;
flex-direction:column;
height: 100%;
}
.fixed{
width: 100%;
line-height: 45px;
font-size: 16px;
background-color: #0088ee;
color: #fff;
text-align: center;
position: fixed;
}
.fixTop{
top: 0px;
}
.fixBottom{
bottom: 0px;
}
.container2{
flex:1;
margin: 55px 10px ;
background-color: #fff;
overflow: scroll;
}
</style>
</head>
<body >
<div>
<div class="fixed fixTop">
<span>顶部文字</span>
</div>
<div>
<p>hahaha</p>
</div>
<div class="fixed fixBottom">
<span>底部文字</span>
</div>
</div>
</body>
</html>
注重事项
- 必然在样式表中添加 html,body{height:100%;}
- 理解flex
来源:百闻(微信/QQ号:9397569),转载请保留出处和链接!
本文链接:https://www.ibaiwen.com/web/213460.html
- 上一篇: 短语翻译:怎么把中文翻译成日文
- 下一篇: 华为EMUI9.0系统怎么降级退回到EMUI8.0
- 热门文章
-
WB蒙特利尔(WB Montreal)——欧美十大最差视频游戏开发商
迅猛龙(Velociraptor)——欧美史前十大死亡动物
什么是果酱猫(What Marmalade Cats)?
神奇蜘蛛侠2(The Amazing Spider-Man 2)——欧美最佳蜘蛛侠电影
希瑟(Heather)——欧美十大最佳柯南灰歌
二人梭哈
奥兹奥斯本(Ozzy Osbourne)——欧美十大高估歌手
什么是小脑前下动脉(Anterior Inferior Cerebellar Artery)?
faceu激萌怎么把瘦脸开到最大
我应该知道康涅狄格州的什么(What Should I Know About Connecticut)?
- 热评文章
- 最新评论
-
- 最近访客
-
- 站点信息
-
- 文章总数:200248
- 页面总数:9
- 分类总数:1
- 标签总数:0
- 评论总数:0
- 浏览总数:497