1

I'm working with Visual Studio, ASP.net, HTML, CSS, C# (for the code behind), ADO.net and Javascript/Jquery.

I'm trying to make a web page with some div block and I want that the block never exceed the browser. Do you know : how to add a height size for div even if I change the resolution of my window?

PS: I'm French so, please, don't be matter about my mistake.

Harsh Baid
  • 7,199
  • 5
  • 48
  • 92
user2265252
  • 65
  • 1
  • 5
  • 13
  • possible duplicate of [Make div 100% height of browser window](http://stackoverflow.com/questions/1575141/make-div-100-height-of-browser-window) – jcvandan Apr 17 '13 at 13:00
  • yes give height,width in %, it will not effected by the resolution and also you can give % height,width in point also for eg: height: 90.5%; – Vijay Singh Rana Apr 17 '13 at 13:03

3 Answers3

1

Without further clarification of your senario, one method is to do the following:

HTML

<div id="test">
    My div
</div>

CSS

html, body {height:100%;margin:0;padding:0}
#test {width:100%; height: 100%;position:absolute;}
Dom
  • 218
  • 1
  • 6
1

Setting height to 100% usually works. NOTE: Sometimes padding may push you beyond the browser.

mhd031
  • 61
  • 4
0

I've encountered screen resolution problem before and this solved my problem.

  • If you want your website to dynamically changing whenever your screen resolution change you can use % in your css to all your page, containers, wrappers etc. so that it will adjust on any screen resolution. (problem: This destroys your web design whenever the screen resolution is big)

  • The best solution I find so far and I think other professional websites also is doing is to make your width static or fixed and just let your page get on the center. This will preserve the design you made on your page and everything will stay and looks as it is.

    In your CSS just add this line on your page ,containers, wrappers etc.

    margin:0 auto;

    and your site will be centered to any screen resolution. For more examples and to read more about it check this reference How to Center a Website With CSS. If you want to test different screen resolutions without changing your actual screen resolution you could try it here.

    Hope this helps :)
bot
  • 4,841
  • 3
  • 42
  • 67