6

What I want to know is how to have a <div> half way across the screen and height 100% no matter the screen resolution and window size resolution.

Thankyou all for your replies they all helped me! Sorry if this question was a little confusing, I have not really done any css before so I didnt know how to phrase it really...Thankyou once again!

user2413519
  • 105
  • 1
  • 2
  • 8

5 Answers5

3

In your reaction to @Arpit I understand you want to center the div no matter the screen resolution.

Try this:

#div {
    width: 800px;
    margin: 0 auto;
}

Different technique is:

#div {
    width: 800px;
    position: absolute;
    left: 50%;
    margin-left: -400px;
}
Paul van den Dool
  • 2,882
  • 3
  • 17
  • 39
1
html,body { height:100%; }
#div_selector { width:50%; margin:0 auto; }
landons
  • 9,444
  • 3
  • 32
  • 46
1

use jsfiddle to make a show :).
Basicly i would think of :

html, body {height:100%;margin:0;}
body {padding-left:50%; */or right */
div.w50h100 {
width:50%;
height:100%;
position:fixed;
top:0;
left:0; /* or right:0; */
}

Okay, you made it clear, and it is simple,

html,body{
    height:100%;
    margin:0;
}
div#center {
    min-height:100%;
    width:XX;
    margin: auto;
}
G-Cyrillus
  • 94,270
  • 13
  • 95
  • 118
0

in css

your_div{
width:50%;  // 50% of current screen size;
}

Demo

Arpit
  • 12,709
  • 3
  • 27
  • 40
  • Right ok thanks that solves some of it, but say if I wanted a specific width like 800px? Altering this changes the position of the div, so that if i view it on larger resolutions it is not in the centre anymore? – user2413519 Jun 03 '13 at 14:06
0

If you choose position style "fixed". The div will orientate itself by the size of the browser window, not by the size of other divs.