css/javascript gurus - help needed, simple question re: centering objects

LordSnailz

Diamond Member
Nov 2, 1999
4,821
0
0
document.getElementById('gallery').style.display = 'block';

Is there anyway to add code in there to center my object? From what I understand, the above replaces id=gallery style to display=block, right?


Originally, I have the following html code -

<table style="width: 790px; text-align: center; margin-left: auto; margin-right: auto; background-color: rgb(165, 154, 132);" cellspacing="7">

All the table items are centered but when add the id=gallery, everything is left aligned --

<table style="width: 790px; text-align: center; margin-left: auto; margin-right: auto; background-color: rgb(165, 154, 132);" id="gallery" cellspacing="7">

In my css, I have

table#gallery
{
margin-left: auto;
margin-right: auto;
display:none;
}

The javascript is suppose to switch it from display:none to block right? It works but all my cell contents are still left aligned, instead of centered.

Any suggestions is greatly greatly appreciated, I've tried everything possible and I'm a css/js noob
 

PseudoKnight

Senior member
Oct 18, 2004
303
0
71
Maybe I'm missing something obvious but I guess it could be a rendering issue. Have you tried it with different browsers?
 

LordSnailz

Diamond Member
Nov 2, 1999
4,821
0
0
PseudoKnight -
weird, you're right, it works in IE but not in FF. Any suggestions on how I can get this to work in FF as well? Hope this narrows down the problem a bit.
 

LordSnailz

Diamond Member
Nov 2, 1999
4,821
0
0
This is my function to set the display to block.

function blah() {
document.getElementById('loadingpic').style.display = 'none';
document.getElementById('gallery').style.display = 'block';
}

what really bugs me is that it looks center on IE but not FF. Is there some css or js bug with FF?
I'll work on getting a test page up soon.

Again any help to resolve this is greatly appreciated!!
 

LordSnailz

Diamond Member
Nov 2, 1999
4,821
0
0
I seems like there's a difference between how FF and IE treats
table#gallery
{
display:none;
text-align: center;
margin-right:auto;
margin-left:auto;
}

It's centered on IE but not FF
 

LordSnailz

Diamond Member
Nov 2, 1999
4,821
0
0
d'oh ... nvm. it doesn't work

Test link again --
-removed- all fixed, thanks to Rogie!

It's centered in IE but not FF
 
Aug 1, 2004
77
0
0
Set tbody, tr, and td to use display:block for the style.
Then add a padding:10px or something to your tbody.
Maybe take out those last few br unless you put another pic there.
And stuff.
 
Aug 1, 2004
77
0
0
That centered it for me. Tested on IE6/7, FF, Mozilla, Opera, Netscape.

Update your test with those changes and let me see. Or pm me if you got AIM/Yahoo.
 

Rip the Jacker

Diamond Member
Dec 29, 2004
5,415
1
76
Originally posted by: Rogie
That centered it for me. Tested on IE6/7, FF, Mozilla, Opera, Netscape.

Update your test with those changes and let me see. Or pm me if you got AIM/Yahoo.

Were you using the JS files he was when you were testing?
 

Rip the Jacker

Diamond Member
Dec 29, 2004
5,415
1
76
That has to be the weirdest code I've ever seen. Starts out all fine with lowercase modern xhtml and then has a load of inline styles, and unnecessary divs + tables (which are uppercase).
=_
 

dukdukgoos

Golden Member
Dec 1, 1999
1,319
0
76
You shouldn't use display: block on a table in a modern browser, they have a special display property called display: table. Rather than setting style.display = "block" use style.display = "", that will set it back to the default value of the property (in this case, "table").
 

LordSnailz

Diamond Member
Nov 2, 1999
4,821
0
0
hey guys, thanks for the replies ... finally got it working thanks to Rogie!!
Yeah, I know everything is butcher together ... total noob here
 
Aug 1, 2004
77
0
0
Originally posted by: dukdukgoos
You shouldn't use display: block on a table in a modern browser, they have a special display property called display: table. Rather than setting style.display = "block" use style.display = "", that will set it back to the default value of the property (in this case, "table").

Even better. Then again I don't like using tables at all anymore.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |