First, the idea of "full screen" is wrong. Javascript DOM objects don't "know" is it a full-screen mode or not, and don't need to "know". You need to develop the layout which works well on whatever the inner size of the browser's window is. I hope this is what you really meant to achieve.
Secondly, your question is not really about CSS, but CSS + JavaScript.
First thing you need to understand is:
to fill in the full window width is the problem totally different from doing the same for height? Why? Because of the floating nature of HTML rendering: the content is flowing left-to-right or right-to-left first, and only then, when the width is filled, it goes down. So, normally, CSS is more than enough to adjust the layout to the width of the window: you use such properties as
width: 100%
. You cannot do the same with height:
even if CSS had the expressive capabilities to fit in the height, it could contradict the horizontal layout properties. Can you see the point?
So, I would not recommend to fit in both width and height for most pages. At the same time, I can see many cases when doing it would be nice or even required. I do such things myself and think that it can make the whole layout paradigm for in-browser JavaScript programming. One apparent example where such layout is important is the game, but not only.
So, here is the idea for JavaScript approach: you need to adjust your layout through calculations based on two properties:
window.innerHeight
and
window.innerWidth
. It can be a bit more complicated than you would expect, because it can be hard to calculate the
actual size of HTML elements.
Anyway, you can find comprehensive example of such layouts in my articles:
JavaScript Calculator,
Tetris on Canvas.
To understand how it works (I hope you already got the idea), you have to read my HTML + CSS and only
small part of JavaScript where the properties mentioned above are used. I tried by best to isolate different part of the script and implement layout separately from other code, so learning it would be easy.
—SA