This is a discussion on "Position image in the dead center of my webpage" within the Web Page Design section. This forum, and the thread "Position image in the dead center of my webpage are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Position image in the dead center of my webpage
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Position image in the dead center of my webpage
I need to get my image centered in the middle of my webpage, so when a browser using a resolution greater then 800x600 is used the imaged is cleanly centered in the middle of the screen.
I've been playing around with my CSS-settings, but so far no luck. .oneColElsCtr #container { width: 46em; background: #FFFFFF; margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */ text-align: left; /* this overrides the text-align: center on the body element. */ } Can anyone tell me what I need to add to get my image to center properly? |
|
|
|
|||
|
Re: Position image in the dead center of my webpage
Quote:
|
|
|||
|
Re: Position image in the dead center of my webpage
i read an interesting article somewhere. if you use the following code it works perfectly:
eg. a 200x100 image for horizontal center {position:absolute; left:50%; margin-left:-100px;} for vertical center {position:absolute; top:50%; margin-top:-50px;} basically the margin is half of the width of the element in negative hope this helps |
|
|||
|
Re: Position image in the dead center of my webpage
oh yeah, so for both you use both in the same bit...
{position:absolute; left:50%; top:50%; margin-left:-100px; margin-top:-50px;} |
|
|||
|
Re: Position image in the dead center of my webpage
Perfect.
I changed my css to: .oneColElsCtr #container { position: absolute; width: 46em; left: 50%; top: 50%; background: #FFFFFF; /* margin: 0 auto; the auto margins (in conjunction with a width) center the page */ margin-left: -400px; margin-top: -300px; text-align: left; /* this overrides the text-align: center on the body element. */ } And the image alligns perfectly. |
|
||||
|
Re: Position image in the dead center of my webpage
That's helpful, a lot of people need absolute centered pages for splash pages.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|||
|
Re: Position image in the dead center of my webpage
please note: i havent tested this in IE6. when i have used similar principles on other pages i have found that IE6 hasnt displayed it properly. so watch out. someone might want to check this!!
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to center webpage | daan | Web Page Design | 20 | Jan 4th, 2008 00:25 |
| How to center an image | Pádraig | Starting Out | 8 | Jun 12th, 2007 12:27 |
| how to center my webpage? | wasku | Web Page Design | 10 | Jan 4th, 2007 20:14 |
| center align text/background image | Lchad | Web Page Design | 5 | Dec 5th, 2006 10:40 |
| Center image within div | hessodreamy | Web Page Design | 6 | Nov 28th, 2005 11:58 |