<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> .box2{ height: 200px; } .left{ width: 200px; height: 200px; background: red; float: left; } .right{ height: 200px; width: 200px; background: blue; float: right; } .center{ height: 200px; background: green; margin: 0 200px; } </style> </head> <body> <div class="box">123</div> <div class="box2"> <div class="left"></div> <div class="right"></div> <div class="center">内容部分</div> </div> </body> </html>
实现两边宽度固定中间变长的标题中间部分要写在最后面,不然右边部分会被挤下去。