摘要:关键词,实现和固定,中间多了滚动,少了撑满和宽度根据内容撑起,当然你可以自己设置小二,上代码来喽布局关键的来啦关键,布局关键,三块主题摆放。
关键词:display: flex,flex: 1, overflow-y: scroll;
实现:head 和footer 固定,中间body多了滚动,少了撑满; head和footer宽度根据内容撑起,当然你可以自己设置........
小二,上代码!
来喽~~
// html布局 <html> <body> <div class="container"> <div class="head">Page Not FoundPage Not FoundPage Not FoundPage Not FoundPagediv> <div class="body"> <div>orry, but the page you were trying to view does not exist.div> <div>shhhhsssdiv> <div>shhhhsssdiv> <div>shhhhsssdiv> <div>shhhhsssdiv> <div>shhhhsssdiv> div> <div class="footer">Page Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not Founddiv> div> body> html>
关键的css来啦!
2 * { 3 line-height: 1.2; 4 margin: 0; 5 } 6 html, body { 7 font-family: sans-serif; 8 height: 100%; 9 width: 100%; 10 } 11 .container{ 12 display: flex; // 关键, flex布局 13 flex-direction: column; // 关键,三块主题column摆放。 14 height: 100vh; // 关键,设置高度为可见高度的100%; 15 } 16 .head{ 17 width: 100%; 18 background: springgreen; 19 } 20 .body{ 21 flex: 1; // 关键, 填充剩余空间 22 width: 100%; 23 background: lightyellow; 24 overflow-y: scroll; // 关键, 超出部分滚动 25 } 26 .footer{ 27 width: 100%; 28 background: goldenrod; 29 }
附上全部代码,可以自己复制到浏览器中打开,看效果~
doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page Not Foundtitle>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
line-height: 1.2;
margin: 0;
}
html, body {
color: #888;
font-family: sans-serif;
height: 100%;
width: 100%;
}
.container{
display: flex;
height: 100vh;
flex-direction: column;
}
.head{
width: 100%;
background: springgreen;
}
.body {
background: lightyellow;
width: 100%;
flex:1;
color: black;
overflow-y: scroll;
}
.footer {
background: goldenrod;
width: 100%;
}
.body div {
height: 200px;
width: 300px;
background: greenyellow;
margin: 20px;
}
style>
head>
<body>
<div class="container">
<div class="head">Page Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not Founddiv>
<div class="body">
<div>orry, but the page you were trying to view does not exist.div>
<div>shhhhsssdiv>
<div>shhhhsssdiv>
<div>shhhhsssdiv>
<div>shhhhsssdiv>
<div>shhhhsssdiv>
div>
<div class="footer">Page Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not FoundPage Not Founddiv>
div>
body>
html>
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/970.html
摘要:关键词,实现和固定,中间多了滚动,少了撑满和宽度根据内容撑起,当然你可以自己设置小二,上代码来喽布局关键的来啦关键,布局关键,三块主题摆放。关键词:display: flex,flex: 1, overflow-y: scroll; 实现:head 和footer 固定,中间body多了滚动,少了撑满; head和footer宽度根据内容撑起,当然你可以自己设置........ 小二,...
摘要:关键词,实现和固定,中间多了滚动,少了撑满和宽度根据内容撑起,当然你可以自己设置小二,上代码来喽布局关键的来啦关键,布局关键,三块主题摆放。关键词:display: flex,flex: 1, overflow-y: scroll; 实现:head 和footer 固定,中间body多了滚动,少了撑满; head和footer宽度根据内容撑起,当然你可以自己设置........ 小二,...
摘要:关键词,实现和固定,中间多了滚动,少了撑满和宽度根据内容撑起,当然你可以自己设置小二,上代码来喽布局关键的来啦关键,布局关键,三块主题摆放。关键词:display: flex,flex: 1, overflow-y: scroll; 实现:head 和footer 固定,中间body多了滚动,少了撑满; head和footer宽度根据内容撑起,当然你可以自己设置........ 小二,...
阅读 3698·2021-10-11 10:59
阅读 1251·2019-08-30 15:44
阅读 3458·2019-08-29 16:39
阅读 2866·2019-08-29 16:29
阅读 1781·2019-08-29 15:24
阅读 790·2019-08-29 15:05
阅读 1249·2019-08-29 12:34
阅读 2281·2019-08-29 12:19