The CSS media queries are very helpful when making a responsive website. They automatically execute the changes when the window size is in its range.
There is another way to detect Browser window size and execute changes is with jQuery which gives you window width and height.
You can use those values to complete your task.