How do you position divs so that they stay in the center in any screen size? |
![]() ![]() |
How do you position divs so that they stay in the center in any screen size? |
Jul 12 2007, 05:18 AM
Post
#1
|
|
|
Senior Member ![]() ![]() ![]() Group: Member Posts: 65 Joined: Sep 2006 Member No: 468,685 |
Like say if i made a layout on my computer screen, which is 1280 by 1024. And then someone on another comp who had a smaller screen went on my myspace, how would i get the DIV to be in the center still.
If that made any sense... Thats the best way i could describe it. |
|
|
|
| *karmakiller* |
Jul 12 2007, 12:51 PM
Post
#2
|
|
Guest |
Try something like this for your div codes:
QUOTE <div class="stuff" style="background-color:000000; width:400px; height:300px; overflow:auto; Change the bolded things.position:absolute;left:50%; top:0%; margin-left:-250px; margin-top:150px; overflow: hidden;"> CONTENT </div> Also, this might be helpful: quick lesson on "position: absolute" top: 0% = moves to top of page top: 50% = moves to middle of page top: 100% = moves to bottem of page left: 0% = moves to left of page left: 50% = moves to center of page left: 100% = moves to right of page margin-left: -15px = moves left 15px margin-left: 15px = moves right 15px margin-top: 45px = moves down 45px margin-top: -45px = moves up 45px |
|
|
|
| *SinfullySweet* |
Jul 13 2007, 01:02 AM
Post
#3
|
|
Guest |
Make the positioning absolute. Make the left properties 50%, and position the divs by changing the left, and right margins.
|
|
|
|
![]() ![]() |