Reply
IE6 Wont Center an Image for its life
Old 03-04-2008, 04:38 PM IE6 Wont Center an Image for its life
Novice Talker

Posts: 5
**** IE6. Dumb**** rat bastards.

Ok, now that I've got that out of my system, what the hell is wrong with IE6 and text-align? It will NOT center an image for the life of it.

Im trying to center an image inside a div:
Code:
<div style="width: 100px; float: right; text-align: center:">
<img src="blah" /><p>Some Text Here</p>
</div>
Of COURSE the text aligns properly but NOT the image. And of course it works in every other single ****ing browser ever made. I am running IE6 in Standards Mode. I have tried:

Code:
margin: 0 auto;
and

Code:
margin-left: auto;
margin-right: auto;
I have wrapped the bastard image in another div and tried to center it thinking the float: right might throw it off. Still no luck. That ****ing bastards glues itself to the left part of the div.

What the **** is wrong with IE6?
qwerty45 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 03-04-2008, 06:08 PM Re: IE6 Wont Center an Image for its life
Gilligan's Avatar
Dead Like Me

Posts: 1,608
Name: Stefan
Location: London, UK
try align="center" instead of the style. Or make it just for ie6

Code:
<div<!--[if IE 6]>
align="center"
<![endif]-->>

Last edited by Gilligan : 03-04-2008 at 06:10 PM.
Gilligan is offline
Reply With Quote
View Public Profile
 
Old 03-04-2008, 06:14 PM Re: IE6 Wont Center an Image for its life
Novice Talker

Posts: 5
No effect.
qwerty45 is offline
Reply With Quote
View Public Profile
 
Old 03-04-2008, 06:49 PM Re: IE6 Wont Center an Image for its life
LadynRed's Avatar
Super Moderator

Posts: 6,406
Location: Tennessee
And not necessary - try this - create a class for the image:

.imgBlock{display: block; margin: 0 auto;}

Add margins and padding as needed.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 03-04-2008, 06:51 PM Re: IE6 Wont Center an Image for its life
vangogh's Avatar
Post Impressionist

Latest Blog Post:
A Focused Blog Is A Happy Blog
Posts: 8,663
Name: Steven Bradley
Location: Boulder, Colorado
The margin: 0 auto approach is the way you want to center the image.

You do need to specify a width and you also need to set a proper doctype. I'm guessing the doctype is the reason it wasn't working.

LadyNRed you beat me to the answer. Are you saying you don't need the doctype and width? Does display: block work instead? Or is that because the image likely has a width on it already?
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum

Last edited by vangogh : 03-04-2008 at 06:52 PM.
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-04-2008, 06:55 PM Re: IE6 Wont Center an Image for its life
Novice Talker

Posts: 5
Still nothing. Welcome to my world.
qwerty45 is offline
Reply With Quote
View Public Profile
 
Old 03-04-2008, 07:59 PM Re: IE6 Wont Center an Image for its life
LadynRed's Avatar
Super Moderator

Posts: 6,406
Location: Tennessee
You do need a proper Doctype, of course. A width isn't necessary on an image and the display:block with the margin: 0 auto; should work, I use this method all the time.

However, QWERTY, you MUST define the width and height of the image in your html, your example doesn't have any dimensions. You should ALWAYS set height and width on the img tag.

It might also be helpful if we could see all the code
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 03-04-2008, 08:20 PM Re: IE6 Wont Center an Image for its life
vangogh's Avatar
Post Impressionist

Latest Blog Post:
A Focused Blog Is A Happy Blog
Posts: 8,663
Name: Steven Bradley
Location: Boulder, Colorado
I got it. I think it works then because you're specifying the width on the img tag. As long as the width is specified somewhere it works. It doesn't have to be in the css.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-05-2008, 12:13 AM Re: IE6 Wont Center an Image for its life
LadynRed's Avatar
Super Moderator

Posts: 6,406
Location: Tennessee
Exactly
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 03-05-2008, 05:28 PM Re: IE6 Wont Center an Image for its life
vangogh's Avatar
Post Impressionist

Latest Blog Post:
A Focused Blog Is A Happy Blog
Posts: 8,663
Name: Steven Bradley
Location: Boulder, Colorado
For a moment I thought you meant that if you used display: block you didn't have to specify the width. I was excited about the new find as only a geek could be.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
| Small Business Forum
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-05-2008, 08:33 PM Re: IE6 Wont Center an Image for its life
LadynRed's Avatar
Super Moderator

Posts: 6,406
Location: Tennessee
LOL
Well, if there's no width specified, there's no way for it to know what the 'auto' on the margins should be.. auto from what ?

Still, it's an easy method and works like a charm
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
LadynRed is offline
Reply With Quote
View Public Profile
 
Old 03-06-2008, 05:49 AM Re: IE6 Wont Center an Image for its life
Experienced Talker

Posts: 47
Name: Bruce
For it to work in IE you'll need it to be in strict mode, Qwerty.
SillyWilly is offline
Reply With Quote
View Public Profile
 
Old 03-06-2008, 02:16 PM Re: IE6 Wont Center an Image for its life
LadynRed's Avatar
Super Moderator

Posts: 6,406
Location: Tennessee
Not necessarily, but there DOES need to be a VALID doctype.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
LadynRed is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to IE6 Wont Center an Image for its life
 

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.16388 seconds with 13 queries