在css佈局中,咱們在不少狀況下須要一變隨瀏覽器寬度變更而變更css
左側固定html
<!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>