Forum Moderators: open
max-width which will do the trick. The only problem is that Internet Explorer (what a surprise) doesn't support it. So, you need to use an IE-only CSS expression to do the same for IE. Combine the two and you get this: .classname {
max-width:650px; /* for standards-compliant browsers */
width:expression(document.body.clientWidth > 650? "650px": "auto" ); /* max-width expression for IE only */
} Ugly code, but functional.
So will it work for the entire webpage display like this?
html, body {
background-color:#fff;
color:#000;
max-width:1200px;
width:expression(document.body.clientWidth > 1200? "1200px": "auto" );
margin:0;
padding:0;
}
Thanks
However do a WM search and you shall get an answer
I remember a while ago a thread that answered precisely to your question
BTW
if the above code works for encyclo, why not for you?
(I did not get the chance to try it, I will later today)
Anyway, testing showed that it [the IE code] doesn't work and in addition, doesn't validate.
To answer in reverse order, it will never validate: it is a proprietary Microsoft solution which inserts Javascript expressions into CSS. I said it was ugly!
I should have been more specific about the bugs that you're going to encounter when using this technique. Here's my first test page:
<html>
<head>
<title>testing max-width expressions</title>
<style type="text/css">
p {
background:#ff0;
border:2px solid black;
max-width:600px;
width:expression(document.body.clientWidth > 600? "600px": "auto" );
}
</style>
</head>
<body>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
</body>
</html> This works just fine, but notice the lack of doctype. If you add a doctype to force the browser into standards-compliance mode, the expression doesn't work... unless you're using absolute positioning:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>testing max-width expressions</title>
<style type="text/css">
p {
position:absolute;
top:10px;
left:10px;
background:#ff0;
border:2px solid black;
max-width:600px;
width:expression(document.body.clientWidth > 600? "600px": "auto" );
}
</style>
</head>
<body>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
</body>
</html> Now, I'm not a Javascript guru (as I said, the expression is pure Javascript), so I'll leave it to someone with better JS knowledge to see if they can alter
document.body.clientWidth into something which will work in standards-compliance mode.
your thoughts?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>testing max-width expressions</title>
<style type="text/css">
p {
position:relative;
top:0px;
left:0px;
background:#ff0;
border:2px solid black;
max-width:400px;
width:expression(document.body.clientWidth > 400? "400px": "auto" );
}
</style>
</head>
<body>
<table border="2">
<tr>
<td width="300">
aaaaaaaaaaaaaaaaa
</td>
<td>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.</p>
</td>
</tr>
</table>
</body>
</html>
<div class="aa"><p>
and closing
</p></div>
sitll scared using it in production server!
it looks like the answer to a long time quest
your thoughts?
Henry
Are you trying to have a fixed-width left-hand column and the right-hand column fluid but restricted to 400px?