响应式布局 大中小屏幕

最近在研究响应式布局,觉得挺好用的。给大家分享一下:

<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title></title> <style> *{ padding:0; margin:0; } .container{ background-color: #ffff00; margin:auto; } header{ 100%; height:100px; background: red; } .left-nav{ background: blue; height:500px; } .content{ background: green; height:500px; } .right-aside{ background: bisque; height:500px; } footer{ 100%; height:100px; background: #00ffff; clear:both; } .left-nav input{ display: none; } @media screen and (min- 992px){ .container{ 992px; } .left-nav{ 200px; float:left; } .content{ 500px; float:left; } .right-aside{ 292px; float:left; } } @media screen and (min-768px) and (max-992px){ .container{ 768px; } .left-nav{ 150px; float:left; } .content{ 618px; float:left; } .right-aside{ display:none; } } @media screen and (max-768px){ .container{ 100%; } .left-nav{ 100%; height:50px; } .content{ 100%; } .right-aside{ display:none; } .left-nav input{ display: block; } } .height{ height:500px; } </style> </head> <body> <div class="container"> <header> </header> <nav class="left-nav"> <input type="button" value="更多" onclick="more()"/> </nav> <section class="content"> </section> <aside class="right-aside"> </aside> <footer> </footer> </div> </body> <script src="../js/jquery-1.9.1.min.js"></script> <script> function more(){ $(".left-nav").toggleClass("height"); } </script> </html>










原文地址:https://www.cnblogs.com/htuthf/p/4581695.html