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
  • 3,020
  • 3
  • 20
  • 44
  • Could you close the post by checking my answer as the correct answer please? It still appears as open. (hover you mouse on the left side of my answer, you'll see the marker turn green) – Paul van den Dool Jun 03 '13 at 14:45
1
html,body { height:100%; }
#div_selector { width:50%; margin:0 auto; }
landons
  • 9,502
  • 3
  • 33
  • 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
  • 101,410
  • 14
  • 105
  • 129
0

in css

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

Demo

Arpit
  • 12,767
  • 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.