ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 左侧固定,右侧自适应 ***** ``` //结构 <div class="demo"> <div class="left"></div> <div class="right"></div> </div> ``` 表现形式 ![](https://img.kancloud.cn/e9/58/e958c4f1d1b78f4a78a2831c46ec3d04_1437x271.png) ## 1.Flex ``` <style> * { padding: 0; margin: 0; } .demo { overflow: hidden; display: flex; } .left { width: 200px; height: 200px; background-color: red; } .right{ height: 200px; background-color: aquamarine; flex: 1; } </style> ``` ## 2.float + BFC ``` <style> * { padding: 0; margin: 0; } .demo { overflow: hidden; } .left { width: 200px; height: 200px; background-color: red; float: left; } .right { height: 200px; background-color: aquamarine; /* 形成BFC盒子 */ overflow: auto; } </style> ``` ## 3.float + margin-left ``` <style> * { padding: 0; margin: 0; } .demo { /* 清除浮动 */ overflow: hidden; } .left { width: 200px; height: 200px; background-color: red; float: left; } .right { height: 200px; background-color: aquamarine; /* 固定盒子的宽度 */ margin-left: 200px; } </style> ```