CSS provides only limited (semi) events, however you can use width or orientation queries to apply different styles depending on the width of the window.
Thus, for some browsers you can use:
@media all and (orientation:portrait) { body { color: red; } }
That will paint all the text red if the width of the window is less than its height.
More precisely, you can use width:
@media all and (max-width:800px) { body { color: red; } }
Codes will color the text red if the width of the window is less than 800 pixels. Try changing this page to see the effect.
To be more precise, javascript is required.
source share