11 December 2016

Resizable Div based on browser window height

Below is an example of how you can use jQuery to create a resizable div which will adjust to your browser height
 <html>  
 <head>  
   <script src="~/Scripts/jquery-1.10.2.min.js"></script>  
 </head>  
 <body>  
   <style>  
     #divResizeable {  
       background-color: orange;  
       width: 100%;  
       height: 200px;  
       min-height :200px;  
     }  
   </style>  
   <div id="divResizeable">  
   </div>  
   <script>  
     $(document).ready(function () {  
       ResizeEvent();  
     });  
     window.onresize = function (event) {  
       ResizeEvent();  
     }  
     function ResizeEvent() {  
       dh = $(window).height() - 200;  
       $("#divResizeable").css({ "height": dh + "px" });  
     }  
   </script>  
 </body>  
 </html>  

No comments:

Post a Comment