左侧固定,右侧自适应

方法一: <style> .box1{ width: 100px; height: 500px; float: left; background-color: red; } .box2{ margin-left: 100px; height: 500px; background-color: blue; } </style> <body> <div class="box1"></div> <div class="box2"></div> </body> 

方法二:<style> .box1{float: left;width: 300px;height: 150px;background: red;} .box2{background: yellow;height: 150px;overflow: auto;} </style> <body> <div class="box1"></div> <div class="box2"></div> </body>

方法三:<style> .box{display: table;width: 100%;} .box1{width: 300px;height: 150px;background: red;display: table-cell;} .box2{background: green;height: 150px;display: table-cell;} </style> <body> <div class="box"> <div class="box1"></div> <div class="box2"></div> </div> </body>

方法四:<style> .box1{width: 20%;height: 150px;background: red; float: left;} .box2{width: 80%;background: green;height: 150px;} </style> <body> <div class="box1"></div> <div class="box2"></div> </body>

方法五:<style> .box{display: flex;} .box1{flex: 1; width: 200px;height: 150px;background: red; } .box2{ flex:4;background: green;height: 150px;} </style> <body> <div class="box"> <div class="box1"></div> <div class="box2"></div> </div> </body>

方法六:<style> .box{position: relative;} .box1{position: absolute; width: 200px;height: 150px;background:yellow; left: 0;} .box2{ padding-left:200px;background: green;height: 150px;} </style> <body> <div class="box"> <div class="box1"></div> <div class="box2"></div> </div> </body>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值