Your Javascript code is placing the <div> using absolute values in pixels.
Use 'em' or 'ex' units and you are done.
>-- Original Message --
>Reply-To: [EMAIL PROTECTED]
>From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: [wdvltalk] DIV doesn't auto-size
>Date: Mon, 23 Aug 2004 14:02:07 -0400
>
>
>In our current app (a Web front end to an AS/400 "green screen" app) we
have
>a field representing the screen title for each screen, called, oddly enough,
>screenTitle. It is contained in an absolutely positioned DIV with no width
>attribute. Due to the nature of the AS/400 app providing the data, some
>(many) items must be styled post-rendering using javascript. The CSS and
>js
>code I've been using has worked fine up until this one screen, which has
>a
>longer than usual title. On this screen the field is wrapping, which it
>shouldn't do, as far as I know. Here's the CSS for the DIV:
>
>.screenTitle {
> position:absolute;
> margin-left: auto;
> margin-right: auto;
> font-family:Verdana, Arial, Helvetica, sans-serif;
> font-weight:bold;
> font-size:12px;
> color:#000000;
> text-align: center;
> z-index: 10;
> }
>
>Here's the HTML for the element:
>
><div id="screenTitle" class="screenTitle"><!-- -->Display Customer Item
>Reference by UPC Code</div>
>
>And here's the javascript used (called in our initPage function) to center
>the DIV on the screen:
>
>function setCompanyScreenCenter()
>{
>var theNode = getLikeElements("div", "id", "screenTitle");
>// alert('This node\'s ID is ' + theNode[0].id);
> if (theNode[0]) {
> var theWidth = theNode[0].clientWidth;
> if (theNode[0].firstChild.nextSibling) {
> if (theNode[0].firstChild.nextSibling.nodeType == 3) { //text
>node
> var workString =
>theNode[0].firstChild.nextSibling.nodeValue;
> workString = trim(workString);
> theNode[0].firstChild.nextSibling.nodeValue = workString;
> theNode[0].style.left = 730/2 - (theWidth/2) + "px";
>//container DIV width is 730px
> theNode[0].style.width = theWidth;
> } //if (theNode[0].first...
> } //if (theNode[0].first...
> } //if (theNode[0])
>} //function
>
>Everything works fine on every other page. My experience has been that
a
>DIV
>with no width or overflow attribute will automatically expand horizontally
>to accommodate its contents, up to the width of its parent container. I
am
>nonplussed as to why this one doesn't seem to be "following the script,"
>so
>to speak. Any ideas?
>
>Cheers,
>Scott
>
>
>____ ? The WDVL Discussion List from WDVL.COM ? ____
>To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED]
> Send Your Posts To: [EMAIL PROTECTED]
>To set a personal password send an email to [EMAIL PROTECTED] with the
>words: "set WDVLTALK pw=yourpassword" in the body of the email.
>To change subscription settings to the wdvltalk digest version:
> http://wdvl.internet.com/WDVL/Forum/#sub
>
>________________ http://www.wdvl.com _______________________
>
>You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
>To unsubscribe send a blank email to [EMAIL PROTECTED]
>
>To unsubscribe via postal mail, please contact us at:
>Jupitermedia Corp.
>Attn: Discussion List Management
>475 Park Avenue South
>New York, NY 10016
>
>Please include the email address which you have been contacted with.
>
--
Pau Garcia i Quiles
MSN Messenger: [EMAIL PROTECTED]
http://www.elpauer.org
____ � The WDVL Discussion List from WDVL.COM � ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED]
Send Your Posts To: [EMAIL PROTECTED]
To set a personal password send an email to [EMAIL PROTECTED] with the words: "set
WDVLTALK pw=yourpassword" in the body of the email.
To change subscription settings to the wdvltalk digest version:
http://wdvl.internet.com/WDVL/Forum/#sub
________________ http://www.wdvl.com _______________________
You are currently subscribed to wdvltalk as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016
Please include the email address which you have been contacted with.