-3

I need to set the height of my webpage constant in any screen size.Is it possible.Please help.

My content is in a wrap div



<div id="wrap"></div>

Thanks

VeNaToR
  • 49
  • 2
  • 7
  • i think this will help you http://stackoverflow.com/questions/11868474/how-to-make-the-web-page-height-to-fit-screen-height – manoj Mar 20 '14 at 12:03
  • 1
    Use web search and tell us what you have tried. – Ari Mar 20 '14 at 12:20

3 Answers3

1

Well, what is that constant? More details would be helpful. But, have you tried setting the height?--for example.

html, body {
    height: 200px;
}
#wrap {
    height: 200px;
}

You can also try with positioning. This does not require you set the height of html and body as the first example does.

#wrap {
  bottom: 0; /* change this */
  left: 0;
  position: absolute;
  right: 0;
  top: 0; /* and this to fit your requirements */
}
Mohamad
  • 34,731
  • 32
  • 140
  • 219
0

It is very possible to do what you want.

The problem that most developers encounter when trying to do this is that when setting the height of a div to 100% it actually flattens to 0px. This is because 100% of nothing is nothing.

Since the body and html tags are both parent of your div they need to be adjusted first.

What you need to do on your css:

html,body{
    height: 100%;
    width: 100%;
    overflow: hidden;
}

#wrap{
    height: 100%;
    width: 100%;
    overflow: auto;
}
xfuler
  • 38
  • 5
  • actually i need to set the height of my webpage to a particular height when the page load initially in any screen (say 800px).Now when my webpage is loading the content is showing at different heights in different screens when browser initially loads the page. – VeNaToR Mar 20 '14 at 12:28
  • do you want the content to scale as well or just the #wrapper's height? – xfuler Mar 20 '14 at 19:14
  • Is scaling helps this situation? but i need to set the wrapper height constant say 800px in any screen size when the page loads in any browser.How can i do this? – VeNaToR Mar 21 '14 at 03:57
0

its not possible to maintain constant height in different screen sizes

mahesh rocks
  • 61
  • 1
  • 9
  • 1
    This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). – Fabio Antunes Mar 20 '14 at 12:35
  • Please don't add "thank you" as an answer. Instead, vote up the answers that you find helpful. – Venk Mar 20 '14 at 12:40