If you prefer to use jQuery, you can achieve it by the following method:
$('.panel').css('height', $(window).height());
$(window).resize(function() {
$('.panel').css('height', $(window).height());
});
Take a look at the snippet below for an example:
$(".panel").css("height", $(window).height());
$(window).resize(function() {
$(".panel").css("height", $(window).height());
});
body {
background-color: yellow;
padding: 0;
margin: 0;
}
.panel {
background-color: blue;
width: 100px;
}
<div class="panel">
This is the panel
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js" ></script>
You can also achieve the same result with just one line of CSS, using height:100vh;
Check the browser support for vh
(viewport height), Can I use vh
body {
background-color: yellow;
padding: 0;
margin: 0;
}
.panel {
background-color: blue;
height: 100vh;
width: 100px;
}
<div class="panel">
This is the panel
</div>