三种常用方式 实现后台管理系统自适应布局
2022-08-03 09:57:03
260
{{single.collect_count}}

后台管理系统基本都是下图的变体,先上图

下面说说布局实现方式,同一套html如下 

<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>自适应布局</title><link rel="stylesheet" href="./index.css"></head><body><div class="header">header</div><div class="container"><div class="menu">menu</div><div class="container-in">container</div></div><div class="footer">footer</div></body></html>

第一种方式,FLEX布局,FLEX MDN 网址 :FLEX MDN

* {margin: 0;padding: 0;}html, body {width: 100%;height: 100%;display: flex;flex-direction: column;}.header {width: 100%;height: 60px;background: red;}.footer {width: 100%;height: 30px;background: blue;}.container {width: 100%;flex: 1;display: flex;}.menu {width: 60px;height: 100%;background: green;}.container-in {float: left;flex: 1;background: yellow;}

第二种方式,CALC计算属性, CALC MDN 网址: CALC MDN

* {margin: 0;padding: 0;}html, body {width: 100%;height: 100%;}.header {width: 100%;height: 60px;background: red;}.footer {width: 100%;height: 30px;background: blue;}.container {width: 100%;height: calc(100% - 90px);}.menu {float: left;width: 60px;height: 100%;background: green;}.container-in {float: left;width: calc(100% - 60px);height: 100%;background: yellow;}

第三种,BFC方式, BFC MDN简介:BFC MDN

* {margin: 0;padding: 0;}html, body {width: 100%;height: 100%;}.header {width: 100%;height: 60px;background: red;}.footer {width: 100%;height: 30px;background: blue;}.container {width: 100%;height: calc(100% - 90px);}.menu {float: left;width: 60px;height: 100%;background: green;}.container-in {overflow: hidden;background: yellow;}

 

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}