Forum Moderators: not2easy

Message Too Old, No Replies

using IE CSS expressions

         

bendee

1:15 am on Jan 16, 2004 (gmt 0)

10+ Year Member



I'm trying to create a simple two-column liquid layout using IE's CSS javascript expressions to establish a minimum width for the container box. The browser (IE6) hangs when I try to reduce the window size below 815, though. I tried using alternate syntax:

width: expression((document.all?document.body.clientwidth:window.innerwidth)<815?"53em":"90%";));

but the browser seems to ignore that one completely. I thought it might just be this machine, but the layout for this site works fine... argh!

Anyone see what I'm doing wrong?

<style type="text/css" media="screen">
body
{
margin: 0;
padding: 0;
font-family: georgia, times, "times new roman", serif;
color: #000;
background-color: #ddd;
}

#container
{
margin: 1em 5%;
background-color: #FFF;
background-image: url(images/background.jpg);
background-repeat: repeat-y;
border: 1px solid #333;
background-position: right;
width:expression(document.body.clientWidth < 815? "53em" : "90%" );
}

#banner
{
background-color: #666;
border-bottom: 1px solid #333;
}

#banner h1
{
margin: 0;
padding: .5em;
}

#nav
{
float: right;
width: 160px;
margin-right: 10px;
padding-top: 1em;
}

#nav p { margin-top: 0; }

#content
{
padding-top: 1em;
margin: 0 200px 0 2em;
}

#content h2 { margin-top: 0; }

#footer
{
clear: both;
background-color: #666;
padding: 1em;
text-align: right;
border-top: 1px solid #333;
}
</style>
</head>
<body>
<div id="container">
<div id="banner">
<h1>Site name</h1>
</div>
<div id="nav">
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod.
</p>
</div>
<div id="content">
<h2>
Page heading
</h2>
<p>
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. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</p>
<p class="nextbutton">
<a href="JavaScript:history.back()">&lt; Back to tutorial</a>
</p>
</div>
<div id="footer">
Footer stuff here
</div>
</div>
</body>

Birdman

1:26 am on Jan 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would imagine that, since it's javascript, you would have to enclose it in <script> tags for it to work.

#container
{
margin: 1em 5%;
background-color: #FFF;
background-image: url(images/background.jpg);
background-repeat: repeat-y;
border: 1px solid #333;
background-position: right;
width:
<script type="text/javascript">
expression(document.body.clientWidth < 815? "53em" : "90%" );
</script>
}

Purple Martin

2:07 am on Jan 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, you don't use script tags. Here is an MSDN article that explains things:

[msdn.microsoft.com...]

There is an old thread on Webmaster World that contains a better link, but as the site search is down at the moment I can't find it for you.

grahamstewart

3:03 am on Jan 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure about IE expressions, not something I use, but could you be getting caught in a loop?

e.g.

your expression says if the width is less than 815 pixels then set it to 53em - but what if 53em was also be less than 815 pixels. Would that make the rule fire again (and again and again?)

(Maybe not - I'm stabbing in the dark here)

d3signmonk3y

3:56 pm on Jan 28, 2004 (gmt 0)



A co-worker showed me this site about using expression for IE

[svendtofte.com...]

and it looked like a great solution... until I tried it. His example works fine for me until I add a XHTML 1.0 transitional doctype to the page, then it crashes every time. Without the doctype it works like a charm though.

IE 6.0.26