切图布局知识点(三)——左右布局
在css布局中,我们在很多情况下需要一变随浏览器宽度变动而变动
左侧固定
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>左右布局</title> <style> html,body{ height: 100%; } .left { float: left; width: 80px; height: 100%; background-color: red; } .right{ height: 100%; margin-left: 80px; background-color: blue; } </style> </head> <body> <div class="left"></div> <div class="right"></div> </body> </html>
右侧固定
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>左右布局</title> <style> html,body{ height: 100%; } .right{ float: right; width: 80px; height: 100%; background-color: red; } .left { height: 100%; margin-right: 80px; background-color: blue; } </style> </head> <body> <div class="right"></div> <div class="left"></div> </body> </html>