View Full Version : Centering Mike's DHTML scroller

10-10-2006, 07:07 PM
I need to position Mike's DHTML scroller in a centered page layout. The pages are .net aspx generated. So the widget is not finding the div ID in the page for it's x,y position. In other words it can be hard coded but then when the page is minimized or maximized the widget is out of alignment. I need the scroller to align itself inside the div/table layout so it will stay within the boundaries of the moving page.

HELP! :)

10-11-2006, 11:03 AM
Warning: Please include a link to the DD script in question in your post. See this thread (http://www.dynamicdrive.com/forums/showthread.php?t=6) for the proper posting format when asking a question.

Well, centering a relatively positioned DIV, as is the case here, is straightfoward enough in CSS. Unfortunately, a bug in IE means it won't work in that browser, but does in Firefox, Opera etc. Find the HTML code:

<div id="placeholder" style="position:relative; width:420px; height:32px; margin: 0 auto;"> </div>

The code in red centers the scroller. Now, for a cross browser solution, you'd have to use some silly hack. Basically, by adding a style sheet like:

<style type="text/css">

text-align: center;


You cause all elements within the page to be centered in IE, including the scroller. Of course you probably don't want everything centered, so one solution is to define a general DIV that surrounds the entire BODY, with that DIV's alignment set to left:

<div style="text-align: left">
rest of body goes here

You can thank Bill Gates for the extra fun!