Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-24-2012, 03:07 AM   PM User | #1
MrTIMarshall
Regular Coder

 
Join Date: Nov 2010
Posts: 347
Thanks: 44
Thanked 1 Time in 1 Post
MrTIMarshall is an unknown quantity at this point
Absolute Center?

Hello,

I'm trying to achieve an absolute center on my website, however upon changing the screen size, the image does not stay in the center.

http://sunlightgardenservices.co.uk/index-new2.html

Any ideas?

Best Regards,
Tim

Last edited by MrTIMarshall; 11-24-2012 at 09:00 PM..
MrTIMarshall is offline   Reply With Quote
Old 11-24-2012, 03:27 AM   PM User | #2
KULP
Regular Coder

 
Join Date: Mar 2012
Posts: 166
Thanks: 5
Thanked 11 Times in 11 Posts
KULP is an unknown quantity at this point
You need to use these in the CSS for your image:

Code:
margin-left: -[Image Width / 2]px; //find this yourself.
left: 50%;
KULP is offline   Reply With Quote
Old 11-24-2012, 03:28 AM   PM User | #3
Custard7A
Regular Coder

 
Custard7A's Avatar
 
Join Date: Jul 2010
Location: Australia
Posts: 269
Thanks: 32
Thanked 32 Times in 32 Posts
Custard7A is an unknown quantity at this point
This should help: http://www.codingforums.com/showpost...54&postcount=9
Custard7A is offline   Reply With Quote
Old 11-24-2012, 04:09 AM   PM User | #4
KULP
Regular Coder

 
Join Date: Mar 2012
Posts: 166
Thanks: 5
Thanked 11 Times in 11 Posts
KULP is an unknown quantity at this point
Quote:
Originally Posted by Custard7A View Post
Quote:
when the screen gets too small, the content will disappear off the left side without so much as a scrollbar, making that area of the page completely unaccessable
I've never had that problem before. Have an example?
KULP is offline   Reply With Quote
Old 11-24-2012, 05:55 AM   PM User | #5
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello MrTIMarshall,
That post Custard7A links to leaves out two very important requirements, see below:

To center an element you need three things:
  1. a valid DocType
  2. an element with a width
  3. that elements right/left margins set to auto
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Old 11-24-2012, 09:32 AM   PM User | #6
Custard7A
Regular Coder

 
Custard7A's Avatar
 
Join Date: Jul 2010
Location: Australia
Posts: 269
Thanks: 32
Thanked 32 Times in 32 Posts
Custard7A is an unknown quantity at this point
I don't know! I was just thinking how this is the most commonly asked question as far as I've seen, so I thought there should be something stickied about it. That post I linked was sticky in this very section. I've only ever used the margin: auto method.
Custard7A is offline   Reply With Quote
Old 11-24-2012, 04:12 PM   PM User | #7
MrTIMarshall
Regular Coder

 
Join Date: Nov 2010
Posts: 347
Thanks: 44
Thanked 1 Time in 1 Post
MrTIMarshall is an unknown quantity at this point
The problem is, I plan to have grass on either side as well, however this is the center of the website where I need to get this working before I implement anything else.

http://sunlightgardenservices.co.uk/index-new.html

This is what I'm rebuilding so you can see how I was doing things, which will be the same, however I understand how media queries work now so I thought I would start from scratch to look at the other one for reference.

Thank you for the current posts
MrTIMarshall is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:33 AM.


Advertisement
Log in to turn off these ads.