I want to add some css for a div height based on screen height and that div height must be the exact screen height.
Can any one help?
I want to add some css for a div height based on screen height and that div height must be the exact screen height.
Can any one help?
Read about @media screen
@media screen and (max-width: 1024px) {
div{width:1024px;}
}
@media screen and (min-device-width: 1600px) {
div {width: 1500px;}
}
@media screen and (max-device-width: 1600px) {
div {width: 1500px;}
}
Also see
div(width:calc(100% - 20px);}
And java script
<div id="id" style="background-color:black;">text</div>
<script>
document.getElementById('id').style.width=screen.width;
document.getElementById('id').style.height=screen.height;
/*or*/
document.getElementById('id').style.width=window.innerWidth;
document.getElementById('id').style.height=window.innerHeight;
</script>
You could use JavaScript to get the window height using window.innerHeight
(be aware that this value EXCLUDES scrollbars/toolbars).
Full example:
var windowHeight = window.innerHeight;
var div = document.getElementById("div");
div.style.height = windowHeight