Jump to content

vertical-align not working


F1Fan

Recommended Posts

I'm really trying to stop using tables, but I can't seem to get vertical-align to do anything.

 

I have a loading div that covers the whole page. I am trying to have the 300px by 150px div be centered vertically and horizontally. Any help is appreciated.

<div id="pleasewait" style="vertical-align:middle;width:100%;height:100%;background-color:#000000;cursor:wait;display:block;z-index:1;position:fixed;left:0px;top:0px;">
<div style="height:auto;"> </div>
<div style="margin:auto auto auto auto;text-align:center;border: solid 1px black;background-color:#FFFFFF;font-weight:bold;width:300px;height:150px;">
	Please wait...<br><br>
	<image src="images/pleasewait.gif">
</div>
</div>

Link to comment
Share on other sites

This is untested but should work.....

margin auto auto auto auto:?did that do anything  ive never thought of that

 

<div id="pleasewait" style="vertical-align:middle;width:100%;height:100%;background-color:#000000;cursor:wait;display:block;z-index:1;position:fixed;left:0px;top:0px;">
   <div style="height:auto;"> </div>
   <div style="margin:o auto;vertical-align:middle:text-align:center;border: solid 1px black;background-color:#FFFFFF;font-weight:bold;width:300px;height:150px;">
      Please wait...<br><br>
      <image src="images/pleasewait.gif">
   </div>
</div>

Link to comment
Share on other sites

The actual old html 3.0 element - vertical-align - only works within table cells.

 

DropFaith was on the right track.

 

To center a block level select you must, first, always give it a width smaller than its parent select, then use margin:0 auto. What it needs is to use auto to calculate left and right margins in order to center within a parent element.

It obviously will not work on a floated or absolute positioned element.

 

You had used the letter o instead of the "number" zero "0".

 

Position:fixed is also not advised since it, too, is not cross-browser compatible.

z-index:1;position:fixed;left:0px;top:0px; is wasted since you already have width and height at 100% for the main select.

 

"cursor:wait;" this is a dhtml or ajax only element not css. Setting the cursor in CSS is not cross-browser compatible.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.