Link to home
Start Free TrialLog in
Avatar of magnumdirectory
magnumdirectory

asked on

Centering a divider in middle of page?

How do you center a divider in the middle of a page both vertically and horizontally so it's exactly in the middle of a browser?
ASKER CERTIFIED SOLUTION
Avatar of David S.
David S.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
get the window size and find the middle and set the divider.

use
  var wide = window.screen.availWidth
  var high = window.screen.availHeight
Avatar of shadow_shooter
shadow_shooter

Assume that the following is the divider:

<img src="divider.gif" style="width: 200px; margin-left:auto; margin-right:auto;" />

width is the width of your image and divider.gif is the path of the image on the server.