You can read your browser dimensions with jQuerys $document.height or with simple JS via height: window.innerHeight || document.body.clientHeight.
But how do I apply the value to a CSS class?
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.
No need to overcomplicate this – you don’t need to find a way to apply the height to a CSS class. Just give each of your
<div>s a class in the HTML:then use jQuery code similar to this:
to apply the measured height to all elements of that class.
For a more robust solution, attach a function to the
window‘sonresizeevent to recalculate and apply the height whenever the viewport height changes.