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