This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Stylesheets > October 2007 > Table with 100% width of page instead of page in IE7
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Table with 100% width of page instead of page in IE7
|
|
| Charles A. Landemaine 2007-10-25, 6:22 pm |
| I set a table with 100% width to occupy all available space, but in
IE7 it uses more than that, it uses 100% of the page width instead of
100% of the table container. Could you test the page in IE7 and in
other browsers please?
http://auriance.com/docs/tmp/test.html
I'd like the main content and the right menu on the same level. It's
working fine in most browsers except in IE7. Do you know how I can fix
it?
Thanks.
| |
| Charles A. Landemaine 2007-10-25, 10:17 pm |
| Ok, I found out. If I set the container to width: 100%, then the table
fits properly.
| |
| dorayme 2007-10-25, 10:17 pm |
| In article
<1193345447.270895.170870@22g2000hsm.googlegroups.com>,
"Charles A. Landemaine" <landemaine@XXXXXXXXXX> wrote:
> I set a table with 100% width to occupy all available space, but in
> IE7 it uses more than that, it uses 100% of the page width instead of
> 100% of the table container. Could you test the page in IE7 and in
> other browsers please?
>
> http://auriance.com/docs/tmp/test.html
>
> I'd like the main content and the right menu on the same level. It's
> working fine in most browsers except in IE7. Do you know how I can fix
> it?
> Thanks.
Put in a 4.01 Strict doctype:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
right at the top of your html page and this should fix.
--
dorayme
| |
| Charles A. Landemaine 2007-10-26, 6:19 pm |
| On Oct 25, 11:03 pm, dorayme <doraymeRidT...@optusnet.com.au> wrote:
> Put in a 4.01 Strict doctype:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
>
> right at the top of your html page and this should fix.
Thanks dorayme. The problem is that with a doctype I can't enable
quirks mode to use all page height to center a page vertically.
Charles.
| |
|
|
"Charles A. Landemaine" <landemaine@XXXXXXXXXX> wrote in message
news:1193398273.114249.155620@z9g2000hsf.googlegroups.com...
> On Oct 25, 11:03 pm, dorayme <doraymeRidT...@optusnet.com.au> wrote:
>
>
> Thanks dorayme. The problem is that with a doctype I can't enable
> quirks mode to use all page height to center a page vertically.
Then you are screwed. Standards mode does not centre "vertically".
You are solving the wrong problem. You should be looking into why you need
to centre a "page" vertically. Vertically in what? The current viewport?
Why? What does this gain your viewer?
Invoking quirks mode in the couple of browsers that support it is not the
solution.
If you show us what you have to date, even the quirks mode version, we may
be able to help. URL?
--
Richard.
| |
| dorayme 2007-10-26, 6:19 pm |
| In article <TzkUi.5546$CN4.2966@news-server.bigpond.net.au>,
"rf" <rf@invalid.com> wrote:
> "Charles A. Landemaine" <landemaine@XXXXXXXXXX> wrote in message
> news:1193398273.114249.155620@z9g2000hsf.googlegroups.com...
>
> Then you are screwed. Standards mode does not centre "vertically".
>
> You are solving the wrong problem. You should be looking into why you need
> to centre a "page" vertically. Vertically in what? The current viewport?
> Why? What does this gain your viewer?
>
> Invoking quirks mode in the couple of browsers that support it is not the
> solution.
>
> If you show us what you have to date, even the quirks mode version, we may
> be able to help. URL?
Yes, I agree with rf, it is highly unlikely to be a good
solution. The doctype that made your problem disappear on my
Winbox is almost certainly more advantageous overall than a
couple of tactical advantages you may have found. What exactly is
it that you want to vertically centre? Is it something small that
is somehow more attractive on most?/average?/medium?
screens/browser sizes?
--
dorayme
| |
| Charles A. Landemaine 2007-10-26, 6:19 pm |
| On Oct 26, 8:54 am, "rf" <r...@invalid.com> wrote:
> Then you are screwed. Standards mode does not centre "vertically".
Yeah, I know, the view port stops where the content stops and not in
the lower boundary of the screen.
> You are solving the wrong problem. You should be looking into why you need
> to centre a "page" vertically. Vertically in what? The current viewport?
> Why? What does this gain your viewer?
Yes, centered vertically and horizontally in the browser. I can
achieve it in quirks mode:
http://auriance.com/docs/tmp/notcenter.html
If I add the doctype, I'm in standard mode and it doesn't work
anymore:
http://auriance.com/docs/tmp/notcenter.html
> Invoking quirks mode in the couple of browsers that support it is not the
> solution.
Ok, I actually can achieve it in standard mode but only stuffing the
code with javascript and lately I have dropped it, I'm using quirks
mode with less code. If you have another suggestion, please let me
know.
Thanks,
Charles.
| |
|
| On 2007-10-26, Charles A. Landemaine <landemaine@XXXXXXXXXX> wrote:
[...]
> http://auriance.com/docs/tmp/notcenter.html
[...]
> Ok, I actually can achieve it in standard mode but only stuffing the
> code with javascript and lately I have dropped it, I'm using quirks
> mode with less code. If you have another suggestion, please let me
> know.
Well, this should work in strict mode in Firefox, Opera and Konqueror:
html, body
{
margin: 0;
padding: 0;
height: 100%; /* I suspect this is what quirks mode is giving
you in this case */
}
table
{
width: 100%;
height: 100%;
}
td
{
/* These are preferable to align="center" */
vertical-align: middle;
text-align: center;
}
<body>
<table>
<tr>
<td>Centre of screen</td>
</tr>
</table>
</body>
| |
|
|
| Charles A. Landemaine 2007-10-27, 6:16 am |
| On Oct 26, 5:54 pm, Ben C <spams...@spam.eggs> wrote:
> Well, this should work in strict mode in Firefox, Opera and Konqueror:
>
> html, body
> {
> margin: 0;
> padding: 0;
> height: 100%; /* I suspect this is what quirks mode is giving
> you in this case */
> }
> table
> {
> width: 100%;
> height: 100%;
> }
> td
> {
> /* These are preferable to align="center" */
> vertical-align: middle;
> text-align: center;
> }
>
> <body>
> <table>
> <tr>
> <td>Centre of screen</td>
> </tr>
> </table>
> </body>
Thanks, indeed, it's working fine: http://auriance.com/docs/tmp/xhtml.html
I could remove safely "padding: 0;" from html, body, it's still
working fine. What I don't understand is that the browsers consider
the viewport is all the window and not the content (just one line).
What do you think?
Thanks anyway :-)
Charles.
| |
|
| On 2007-10-27, Charles A. Landemaine <landemaine@XXXXXXXXXX> wrote:
> On Oct 26, 5:54 pm, Ben C <spams...@spam.eggs> wrote:
[...]
> Thanks, indeed, it's working fine: http://auriance.com/docs/tmp/xhtml.html
> I could remove safely "padding: 0;" from html, body, it's still
> working fine.
Most browsers have a bit of margin on body by default, but some may use
padding instead, so it's safer to set both to 0. The idea is to make
sure that body's content area is exactly the same as the viewport, no
smaller, or you'll end up with an annoying short scroll bar.
> What I don't understand is that the browsers consider
> the viewport is all the window and not the content (just one line).
> What do you think?
That's just what the viewport is defined as. Its dimensions are whatever
the user sized the window to.
| |
| Charles A. Landemaine 2007-10-28, 7:19 pm |
| On Oct 27, 8:24 am, Ben C <spams...@spam.eggs> wrote:
> Most browsers have a bit of margin on body by default, but some may use
> padding instead, so it's safer to set both to 0. The idea is to make
> sure that body's content area is exactly the same as the viewport, no
> smaller, or you'll end up with an annoying short scroll bar.
I'll keep it, then.
> That's just what the viewport is defined as. Its dimensions are whatever
> the user sized the window to.
Alright, thanks for everything :)
Charles.
| |
| Charles A. Landemaine 2007-10-28, 11:16 pm |
| On Oct 26, 5:54 pm, Ben C <spams...@spam.eggs> wrote:
> Well, this should work in strict mode in Firefox, Opera and Konqueror:
>
> html, body
> {
> margin: 0;
> padding: 0;
> height: 100%; /* I suspect this is what quirks mode is giving
> you in this case */
> }
> table
> {
> width: 100%;
> height: 100%;
> }
> td
> {
> /* These are preferable to align="center" */
> vertical-align: middle;
> text-align: center;
> }
>
> <body>
> <table>
> <tr>
> <td>Centre of screen</td>
> </tr>
> </table>
> </body>
Hello guys,
Me again :-)
The above doesn't work with a division, does it?
http://auriance.com/docs/tmp/xhtml.div.html
Please let me know, thanks.
Charles.
| |
|
| On 2007-10-29, Charles A. Landemaine <landemaine@XXXXXXXXXX> wrote:
> On Oct 26, 5:54 pm, Ben C <spams...@spam.eggs> wrote:
>
>
>
> Hello guys,
>
> Me again :-)
> The above doesn't work with a division, does it?
> http://auriance.com/docs/tmp/xhtml.div.html
No. Vertical-align: middle means something different when not applied to
a table cell.
It means align text to the middle of the line box instead of to the
baseline (actually it means move it up from the baseline by half the
ex-height of the div's "strut") In this case it just moves your text up
by a small number of pixels.
Vertical centering is not easy to achieve without tables or display:
table unless you're prepared to set an explicit height. If you've really
got just one line of text saying something like "Centre of screen" then
you can just set the div's height to 1.2em or so.
If you can set width and height something like this should work:
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
height: 1.2em;
width: 15em;
text-align: center;
See also http://www.student.oulu.fi/~laurirai/www/css/middle/
| |
| Charles A. Landemaine 2007-10-29, 7:18 pm |
| On Oct 29, 5:41 am, Ben C <spams...@spam.eggs> wrote:
> If you can set width and height something like this should work:
>
> position: absolute;
> top: 0;
> bottom: 0;
> left: 0;
> right: 0;
> margin: auto;
> height: 1.2em;
> width: 15em;
> text-align: center;
>
> See alsohttp://www.student.oulu.fi/~laurirai/www/css/middle/
Thanks Ben. Actually, text will be "Loading..." :)
I tried your suggestion, it's working fine in Opera but not IE7 :(
http://auriance.com/docs/tmp/xhtml.div.html
I read the article (pretty good). The problem in my case is that
height is variable...
Any idea?
Thanks,
Charles.
| |
|
| On 2007-10-29, Charles A. Landemaine <landemaine@XXXXXXXXXX> wrote:
> On Oct 29, 5:41 am, Ben C <spams...@spam.eggs> wrote:
>
>
>
> Thanks Ben. Actually, text will be "Loading..." :)
> I tried your suggestion, it's working fine in Opera but not IE7 :(
> http://auriance.com/docs/tmp/xhtml.div.html
> I read the article (pretty good). The problem in my case is that
> height is variable...
If it's just one line-- "Loading..."-- then I was thinking you could set
the height to about 1.2em. That should be about the right size.
Otherwise you need a table, and if you want it to work in IE, that means
a <table>.
| |
| Charles A. Landemaine 2007-10-29, 7:18 pm |
| On Oct 29, 12:21 pm, Ben C <spams...@spam.eggs> wrote:
> If it's just one line-- "Loading..."-- then I was thinking you could set
> the height to about 1.2em. That should be about the right size.
>
> Otherwise you need a table, and if you want it to work in IE, that means
> a <table>.
Thanks Ben, yes, in my case I'll use this: http://auriance.com/docs/tmp/align.div.html
Seems to be working fine in most browsers. If I need to center a Flash
movie, I'll take care of the height of the movie and I'll substract
1/2 of its height in the negative top margin to keep it centered :)
Cheers,
Charles.
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|