I’m guessing that because you can do this with Media Queries:
@media (min-width:500px) { … }
That at some point or another, the CSS stylesheet must know what width the screen is, sans Javascript.
Is this the case?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use
device-widthwhich will test of the screen’s width in px. That however is not entirely recommended. Usemax-widthandmin-width(for the viewport) instead.If you are trying to GET the screen width and use it (something like
content: (device-width);of some sort, that’s not possible. Stick with JavaScript.Manual Reference