table height=90%

G

gilgames

The page below works fine in IE and in NS4 but in NS7.1 the height of
the table is only the height of the image. Any idea appreciated

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head></head><body><center><br>
<table border=0 bgcolor='aqua' width='100%' height='90%'>
<tr><td align='center' valign='middle'>
<img SRC="../../www/wpm/images/apple.jpg">
</td></tr></table></center></body></html>
 
S

Steve Pugh

gilgames said:
The page below works fine in IE

That depends. If you ahd triggered standards mode rather than quirks
mode with your doctype then IE6 would also ignore the height.
and in NS4 but in NS7.1 the height of
the table is only the height of the image. Any idea appreciated

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head></head><body><center><br>
<table border=0 bgcolor='aqua' width='100%' height='90%'>

There is no attribute height for the table element, so more compliant
browsers ignore it.

Steve
 
G

gilgames

<<
There is no attribute height for the table element, so more compliant
browsers ignore it.

Steve

You right. It seems to me strange this worked earlier and quite usefull,
and also height with absolute number (instead of percentage) works.

So how can I position an image to the middle of a frame if I dont know
the size of the image, and the user should be able to resize the frame?

In the reality I make user sized images in fly, and the image has to be
on the middle of a frame, having some user defined background color
around the image (to see the effect of the transparanecy and such).

CSS HEIGHT and VERTICAL-ALIGN didn't work either (w/o table for a DIV
element)

By definition TD has height element, but that doesn't extends the table
 
W

Weyoun the Dancing Borg

gilgames said:
The page below works fine in IE and in NS4 but in NS7.1 the height of
the table is only the height of the image. Any idea appreciated
<table border=0 bgcolor='aqua' width='100%' height='90%'>


well firstly it should be <table height="90%"> because single quotes are
not part of the HTML specification AFAIK (but someone please make me wrong)

secondly, the "height" attribute is not part of the HTML 4.01 specification.



--

Quiet, Pinky; I'm pondering.
_ _
/~\\ \ //~\
| \\ \ // |
[ || || ]
] Y || || Y [
| \_|l,------.l|_/ |
| >' `< |
\ (/~`--____--'~\) /
`-_>-__________-<_-'
/(_#(__)#_)\
\___/__\___/
/__`--'__\
/\(__,>-~~ __)
/\//\\( `--~~ )
'\/ <^\ /^>
_\ >-__-< /_
(___\ /___)
 
W

Weyoun the Dancing Borg

gilgames said:
<<
There is no attribute height for the table element, so more compliant
browsers ignore it.

Steve

You right. It seems to me strange this worked earlier and quite usefull,
and also height with absolute number (instead of percentage) works.

So how can I position an image to the middle of a frame if I dont know
the size of the image, and the user should be able to resize the frame?

<div align="center"><img src="image.jpg"></div>

As for controlling it's verticle middle, use CSS.



--

Quiet, Pinky; I'm pondering.
_ _
/~\\ \ //~\
| \\ \ // |
[ || || ]
] Y || || Y [
| \_|l,------.l|_/ |
| >' `< |
\ (/~`--____--'~\) /
`-_>-__________-<_-'
/(_#(__)#_)\
\___/__\___/
/__`--'__\
/\(__,>-~~ __)
/\//\\( `--~~ )
'\/ <^\ /^>
_\ >-__-< /_
(___\ /___)
 
G

gilgames

<<


<html><head></head><body>
<DIV ALIGN=CENTER
style="{HEIGHT:90%;WIDTH:90%;BACKGROUND-COLOR:AQUA;VERTICAL-ALIGN:MIDDLE}">
<img SRC="../../www/wpm/images/apple.jpg" style="{VERTICAL-ALIGN:MIDDLE}">
</DIV></body></html>


Here is CSS, the HEIGHT and WIDTH properties work, the VERTICAL-ALIGN
does not, this time neither in IE.

Apparanetly I have to get the image size in javascript and reposition
it, which is yucky.

What drives me crazy, that in the original TABLE version the HEIGHT
NS71. accepts the absolute number, only the percentage in skipped.

Thank for the help anyway.
 
M

Mark Parnell

well firstly it should be <table height="90%"> because single quotes are
not part of the HTML specification AFAIK (but someone please make me wrong)

You're wrong. :)

<quote>
"By default, SGML requires that all attribute values be delimited using
either double quotation marks (ASCII decimal 34) or single quotation
marks (ASCII decimal 39)"
....
"In certain cases, authors may specify the value of an attribute without
any quotation marks."
</quote>
http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2
 
S

Steve Pugh

gilgames said:
<html><head></head><body>
<DIV ALIGN=CENTER
style="{HEIGHT:90%;WIDTH:90%;BACKGROUND-COLOR:AQUA;VERTICAL-ALIGN:MIDDLE}">
<img SRC="../../www/wpm/images/apple.jpg" style="{VERTICAL-ALIGN:MIDDLE}">
</DIV></body></html>

Here is CSS, the HEIGHT and WIDTH properties work, the VERTICAL-ALIGN
does not, this time neither in IE.

What on earth made you think that style="{...}" was correct syntax?
None of you styles above will be honoured in any browser that doesn;t
bend over backwards to correct totally trashed code.

And even if the syntax was correct the above wouldn't help you.
Because vertical-align does not apply to block elements like div. It
only applies to elements with the display property set to either
inline or table-cell.

In this case setting vertical-align on the inline element (<img>) does
no good as there is no other in line elements for it to align with.
Nor does setting display: table-cell on the div because (amongst other
reasons) IE doesn't support display: table-cell.

So we're back to a version of your original code, which horrible
bastard of CSS and presentational HTML does do what you want in all
relatvely modern browsers and also validates.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title>The title element is mandatory</title>
<style type="text/css">
html,body {height: 100%;}
table {height: 90%; width: 100%; border: none;}
td {text-align: center; vertical-align: middle; background: aqua none;
color: black;}
</style>
</head>
<body>
<table><tr><td>
<img src="../../www/wpm/images/apple.jpg" alt="Never forget to include
alternative text">
</td></tr></table>
</body>
Apparanetly I have to get the image size in javascript and reposition
it, which is yucky.

That's one way to proceed, but if the user's browser is smaller than
the image you may find that you've made portions of the image
inacessable. If that's an acceptable consequence for you then setting
the image as a bcakground image is easier than messing about with JS.

<DIV style="height: 90%; width :90%; background-color: aqua;
background-image: url(../../www/wpm/images/apple.jpg);
background-position: center center;"></DIV>

And if you trigger Standards mode then you need (as my example above)
to set html, body {height: 100%;}, otherwise the height: 90% won't be
treated as 90% of the window height.
What drives me crazy, that in the original TABLE version the HEIGHT
NS71. accepts the absolute number, only the percentage in skipped.

Yes, that looks like a bug. Both should be ignored.

Steve
 
T

Toby A Inkster

Steve said:
Very funny. A working draft that hasn't been worked in for two years
and which AFAIK no browser manufacturer has announced support for.

Yet it's the only document that even makes an attempt to define a standard
for what goes between 'style="' and the following '"'. (The HTML and XHTML
specs simply declare it as CDATA).

And very many HTML rendering engines (Trident, Tasman, Gecko, Presto,
KHTML, Netscape 4, iCab) support a limited subset.
 
L

laszlo

Thanks for the help for all.

As for myself I settled with the resolution below, ugly but works. It
expands a 1x1 nullimage for a properly colored and framed background
to the proper size, and positions the image to the center. (Steve's
sample works but I realized that I need to know the exact geometry of
myimage on the screen anyway.

<html>
<head><title>Do not worship the standards</title>
<SCRIPT TYPE="text/JavaScript" LANGUAGE=JavaScript1.2>

function startup() {
var ww = (document.innerWidth) ? document.innerWidth
: (document.body.clientWidth) ? document.body.clientWidth
: screen.availWidth;
var wh = (document.innerHeight) ? document.innerHeight
: (document.body.clientHeight) ? document.body.clientHeight
: screen.availHeight;
var a = document.images[0];
if (a) {a.style.width = ww-100;
a.style.height=wh-100;a.style.visibility='visible'}

var iw = 100;
var ih = 100;
var b = document.images[1];
if (b) {iw = b.width; ih = b.height;}
var x = Math.floor(ww/2 - iw/2);
var y = Math.floor(wh/2 - ih/2);
if (x < 0) x = 0;
if (y < 0) y = 0;
if (b) {b.style.left = x; b.style.top = y; b.style.visibility =
'visible';}
}
</SCRIPT>

</head>
<body background='black' onload='startup()'>

<IMG SRC=nullimage.gif ALT="ditto"
STYLE={position:absolute;top:50;left:50;width:600;height:500;background:aqua;visibility:hidden}>

<IMG SRC=myimage.png
STYLE={position:absolute;top:0;left:0;visibility:hidden} ALT="ditto">
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top