宽度固定,上栏高度固定,下栏高度自适应。
1.flex布局
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> * { padding: 0; margin: 0; } html, body { height: 100%; } .content { display: flex; flex-direction: column; width: 100%; height: 100%; } .top { width: 100%; height: 200px; background-color: blue; } .bottom { width: 100%; flex: 1; background-color: red; } </style> </head> <body> <div class="content"> <div class="top"></div> <div class="bottom"></div> </div> </body> </html>
2.绝对定位布局
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> * { padding: 0; margin: 0; } html, body { height: 100%; } .content { position: relative; width: 100%; height: 100%; } .top { position: absolute; width: 100%; top: 0; left: 0; height: 200px; background-color: blue; } .bottom { position: absolute; top: 100px; left: 0; width: 100%; height: 100%; flex: 1; background-color: red; } </style> </head> <body> <div class="content"> <div class="top"></div> <div class="bottom"></div> </div> </body> </html>
原文地址:https://www.cnblogs.com/yiyi111/p/12365341.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。