jquery實現div自適應瀏覽器高度(寬度)


<!DOCTYPE html> <html> <head> <meta charset=UTF-8 /> <title>jquery實現div自適應瀏覽器高度(寬度)</title> <meta name="keywords" content="html5" /> <meta name="description" content="html5 test" /> <script type="text/javascript" src="jquery-1.7.1.min.js"></script> <script type="text/javascript"> function autoHeight() { var h = $(window).height(); var h_old = 300; if (h > h_old) { $(".left").css('height', h); } else { return false; } } $(function() { autoHeight() $(window).resize(autoHeight); }) </script> <style type="text/css"> html, body { margin: 0; height: 100%; } .left { width: 100px; background: #E8EFF6; margin-left: 100px; } </style> </head> <body> <div class="left"> das </div> </body> </html>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM