0

How do I get the page width in a css. Getting window width/height is easy. eg: Height: 100% sets the height to 100% of the window height. I want to set it to 100% of the page size. because if we zoom when using window size, max size it takes is of the window.

2
  • You'll have to explain a little bit more. It sounds like you're using a mobile? Oct 17, 2013 at 13:14
  • I'm not sure what the difference between window and page is, they seem like the same thing to me. Also to clarify, setting width or height to 100% does not fill the window or page, it fills the width of the parent container. The parent container could be the window/document/page (whatever you are calling it) or it could also be another <div> (or other HTML element). Oct 17, 2013 at 13:39

1 Answer 1

0

jquery can give you a solution as follows:

$(window).height();   // returns height of browser viewport
$(document).height(); // returns height of HTML document

so you can use $(document).height();

4
  • 1
    I want to use it in css. Can jQuery be used in css??
    – mashj
    Oct 17, 2013 at 13:23
  • var docHeight = $(document).height(); will get the height of the document then $('your_div').height(docHeight); wil give that height to your div. Oct 17, 2013 at 13:32
  • that works fine. But I want to set the Height in the .CSS file
    – mashj
    Oct 17, 2013 at 13:36
  • I don't think if there is a way to get the height of document with css, you can check this fiddle link to get it with jquery jsfiddle.net/Mohinder/svfhP Oct 17, 2013 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.