Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Firefox won't center tables or divs
Old 01-13-2008, 01:59 AM Firefox won't center tables or divs
Junior Talker

Posts: 4
Name: Chris Burns
Trades: 0
I am currently trying to create a portfolio website and have run into
some problems with the layout. It seems that Firefox won't center my tables or divs, but IE will. I've read online that this can happen sometimes, but it is due to IE actually reading the code incorrectly.

I am using Dreamweaver MX 2004. For the tables, I simply use align=center, and with the divs, I tried a couple types of code. At first, I did margin-right=auto and margin-left=auto, and then later a much more literal way, using left=50%, margin-left=-455 (half of the width of the desired div).

If you want to see what I mean, you can see it at http://newmedia.purchase.edu/~cburns. Any suggestions?

Last edited by iamlevicious; 01-13-2008 at 02:00 AM..
iamlevicious is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-13-2008, 02:02 AM Re: Firefox won't center tables or divs
Skilled Talker

Posts: 52
Name: Dustin
Trades: 0
can we see the code? I might be able to help you out better if I can mess with it a little.
__________________

Please login or register to view this content. Registration is FREE
TributeK is offline
Reply With Quote
View Public Profile
 
Old 01-13-2008, 02:04 AM Re: Firefox won't center tables or divs
Junior Talker

Posts: 4
Name: Chris Burns
Trades: 0
Here is the code the div that I want to use to center all of the content.

#center {
text-align: left;
width: 910px;
margin-right: auto;
margin-left: -455px;
background-color: #CCC;
padding: 0px;
left: 50%;
top: auto;
right: auto;
bottom: auto;
vertical-align: middle;
background-image: url(http://newmedia.purchase.edu/%7Ecbur...res/back.png);
height: auto;
position: absolute;

}
iamlevicious is offline
Reply With Quote
View Public Profile
 
Old 01-13-2008, 02:05 AM Re: Firefox won't center tables or divs
Mattmaul1992's Avatar
Ultra Talker

Posts: 486
Name: Matt
Trades: -1
Your table is only 800 pixels wide.. changing it to 100% would fix the entire problem but my first guess why it works in IE and not firefox is that IE does stuff it doesn't say it's going to do and aligns images/tables with the text-align declaration in CSS and FF doesn't. Don't mix CSS styling with HTML styling.. HORRIBLE idea. Your code will smell the stench of browser incompatibility (like it already is and you have less than 15 lines of code lol) which will result in loss of users, search engines getting confused and skipping your site all together, etc. I'd learn more about what you're doing before you try to sell it.. No offense.
Also tribute all you have to do to see the code is view the source lol :S.
__________________
PHP Code:
$talkupation++; 

Please login or register to view this content. Registration is FREE
- Free IPB forum hosting (releasing today!!!), no ads, free modifications

Last edited by Mattmaul1992; 01-13-2008 at 02:08 AM..
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
Old 01-13-2008, 02:06 AM Re: Firefox won't center tables or divs
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
1) DO NOT USE TABLES FOR LAYOUT!!!!!!

2) The direct answer to your question is to add this to the <head> section:
HTML Code:
<style>
body {
  text-align:center;
}
</style>
3) Use TD to enclosed data in your tables -- don't just put stuff inside of TR tags.

4) This does the same thing as your site and NO TABLES:

HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chris Burns' Advanced Standing Web Portfolio</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
body {
  text-align:center;
  background-image:url('http://newmedia.purchase.edu/~cburns/background.jpg');
}
#page_content {
  text-align:left;
  width:800px;
  margin-left:auto;
  margin-right:auto;
  border:1px #000000 solid;
}
</style>
</head>

<body>
  <div id="page_content">
    <img  align="center" src="http://newmedia.purchase.edu/~cburns/banner.jpg">
  </div>
</body>
</html>
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 01-13-2008, 02:08 AM Re: Firefox won't center tables or divs
Mattmaul1992's Avatar
Ultra Talker

Posts: 486
Name: Matt
Trades: -1
One thing I forgot to mention. If you're using tables NEVER let Dreamweaver format them for you or your site will be ****.. Trust me I've never seen a page Dreamweaver made work better than even the noobiest of developers.
__________________
PHP Code:
$talkupation++; 

Please login or register to view this content. Registration is FREE
- Free IPB forum hosting (releasing today!!!), no ads, free modifications
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
Old 01-13-2008, 02:11 AM Re: Firefox won't center tables or divs
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Quote:
Originally Posted by Mattmaul1992 View Post
One thing I forgot to mention. If you're using tables NEVER let Dreamweaver format them for you or your site will be ****.. Trust me I've never seen a page Dreamweaver made work better than even the noobiest of developers.

Bit of a side note, but I'd like to see Dreamweaver and it's evil cousin -- what is that Microsoft product? -- deleted. A nice del *.* /s. They both lead people to thinking that they can create a website when they should instead learn how websites work behind the scenese.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 01-13-2008, 02:13 AM Re: Firefox won't center tables or divs
Mattmaul1992's Avatar
Ultra Talker

Posts: 486
Name: Matt
Trades: -1
Quote:
Originally Posted by JeremyMiller View Post
Bit of a side note, but I'd like to see Dreamweaver and it's evil cousin -- what is that Microsoft product? -- deleted. A nice del *.* /s. They both lead people to thinking that they can create a website when they should instead learn how websites work behind the scenese.
You need to stop reading my mind lol.
__________________
PHP Code:
$talkupation++; 

Please login or register to view this content. Registration is FREE
- Free IPB forum hosting (releasing today!!!), no ads, free modifications
Mattmaul1992 is offline
Reply With Quote
View Public Profile
 
Old 01-13-2008, 02:19 AM Re: Firefox won't center tables or divs
Junior Talker

Posts: 4
Name: Chris Burns
Trades: 0
OK, well I appreciate all the tips here guys. I am just starting out in
web design, so all the tips help. I've ditched the tables and am going to
use an all CSS layout now. I think part of my problem can be attributed to
the fact that I forgot to properly link my style sheet, so it wasn't reading it at
all.

Thanks
iamlevicious is offline
Reply With Quote
View Public Profile
 
Old 01-13-2008, 02:27 AM Re: Firefox won't center tables or divs
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Quote:
Originally Posted by iamlevicious View Post
I've ditched the tables and am going to
use an all CSS layout now.
That's great news!
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 01-14-2008, 09:01 AM Re: Firefox won't center tables or divs
Novice Talker

Posts: 8
Trades: 0
Type only those two:

display:block;
margin:0 auto;
__________________
Want to learn how to pick up Hot Babes?

Please login or register to view this content. Registration is FREE
przechwyt is offline
Reply With Quote
View Public Profile
 
Old 01-14-2008, 02:38 PM Re: Firefox won't center tables or divs
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
A <div> IS a block-level element, the display:block isn't necessary.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 01-14-2008, 06:25 PM Re: Firefox won't center tables or divs
tkx
Novice Talker

Posts: 7
Trades: 0
Its because FF sucks and IE is so much better.
tkx is offline
Reply With Quote
View Public Profile
 
Old 01-14-2008, 08:09 PM Re: Firefox won't center tables or divs
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
Quote:
Its because FF sucks and IE is so much better.
Clearly, you are out of your mind ! IE is a NIGHTMARE !
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 01-24-2008, 10:17 PM Re: Firefox won't center tables or divs
Junior Talker

Posts: 3
Name: Andy S
Trades: 0
Hmm, I'm having the same problem in FF. But I already have "text-align:center;" in my body tag section. Again, it all centers fine in IE, but not in FF. What else could be going on?

EDIT: This is what I've got. I have searched and searched and I cannot see why it wouldn't center.
Quote:
body {
font-family: Geneva, Arial, Helvetica, sans-serif;
background-color: #BFCBD9;
text-align: center;
}
I CAN get it to center if I put a <center> tag around my body code manually, but I shouldn't have to resort to that! Sheesh!

Last edited by Dubious Drewski; 01-24-2008 at 10:22 PM..
Dubious Drewski is offline
Reply With Quote
View Public Profile
 
Old 01-25-2008, 03:16 AM Re: Firefox won't center tables or divs
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
because only IE6 and below falls for the text-align:center trick on the body, proper browsers use the correct method of;
HTML Code:
margin:0 auto;
along with a fixed width on the element to be centred

( post #11 in this thread if your search missed it)
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-25-2008, 03:55 AM Re: Firefox won't center tables or divs
Junior Talker

Posts: 3
Name: Andy S
Trades: 0
FF is a proper browser and IE6 and below aren't, but FF can't center my page, and IE6 does? I don't get it. I WANT to have my page centered.

I tried adding "margin:0 auto;" to my body tag code, but it did nothing. I'm not sure what that was supposed to do anyway, heh.

So how do I center my page in FF then? I would really like to know.
Dubious Drewski is offline
Reply With Quote
View Public Profile
 
Old 01-25-2008, 04:16 AM Re: Firefox won't center tables or divs
TripleMoons's Avatar
Webmaster Talker

Posts: 619
Name: Stephanie Kunder
Location: Hanover, PA
Trades: 0
Try using this:

Code:
.wrapper {
    width:800px;
    margin:0px auto 0px auto;
}
and wrap it around your web site inside the body tags.

I also noticed you have some incorrect CSS in your center id:

Code:
align:center
text-align;
Which could be causing you problems of some sort.

Use W3C's HTML & CSS validator...It can help prevent cross browser problems (and make sure you're doing things right).
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Last edited by TripleMoons; 01-25-2008 at 04:21 AM..
TripleMoons is offline
Reply With Quote
View Public Profile Visit TripleMoons's homepage!
 
Old 01-25-2008, 04:57 AM Re: Firefox won't center tables or divs
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,380
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by Dubious Drewski View Post
FF is a proper browser and IE6 and below aren't, but FF can't center my page, and IE6 does? I don't get it. I WANT to have my page centered.
Then you have to use correct markup and CSS

Quote:
Originally Posted by Dubious Drewski View Post
I tried adding "margin:0 auto;" to my body tag code, but it did nothing. I'm not sure what that was supposed to do anyway, heh.

So how do I center my page in FF then? I would really like to know.
You don't add it to the body element

see the bolded part of;
Quote:
Originally Posted by chrishirst View Post
because only IE6 and below falls for the text-align:center trick on the body, proper browsers use the correct method of;
HTML Code:
margin:0 auto;
along with a fixed width on the element to be centred
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-25-2008, 12:27 PM Re: Firefox won't center tables or divs
Junior Talker

Posts: 3
Name: Andy S
Trades: 0
Ahh, haha. I had to apply it to the "container" of my content. Or the "wrapper" as you guys call it. I see now. Oh yes. Finally! So, why doesn't Dreamweaver do this for me, I wonder? It does everything else perfectly.

I doubt I'm going to remember "margin:0 auto;" without having to refer back to this thread.
Dubious Drewski is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Firefox won't center tables or divs

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
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.81731 seconds with 12 queries