Jump to content

centre Div


nezbo

Recommended Posts

Hi all

 

I have been looking at centerlizing a div,

 

i have got this in the CSS so for, i am not to sure how to make it stick to the centre of the page when i scrole, at the moment it sticks to the top left corner...

 

please ignore the visibility:hidden; i is made visible with javascript...

 

I am not to use i understand the expression( ( 0 + ( ignoreMe = document.documentElement.scroll....... bits, so i dont know how to make them centered.

 

div#theDiscText
{
position:absolute;
visibility:hidden;
background-color:#FFFFFF;
filter:alpha(opacity=100);-moz-opacity:1.;opacity:1.0;
width:50%;
z-index:200;
border-style:solid;
border-color:#000000;
border-width:1px;
left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
  	top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
}

Link to comment
Share on other sites

Cheers, but this dose not center over the top of the other page contents...

 

the only way i could get it to work is useing the position:absolute; because it puts it in the center of the screen....

 

Any ideas?

Link to comment
Share on other sites

Sorry should have posted more of the code...

 

the fixme does the background and theDiscText does the text box...

 

div#theDiscText
{
position:absolute;
visibility:hidden;
background-color:#FFFFFF;
width:50%;
z-index:200;
border-style:solid;
border-color:#000000;
border-width:2px;
left: 25%;  	
top: expression(( 200 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
}
body > div#theDiscText
{ 
position: fixed;
margin: auto;
top:35%;
left:25%;	
}

div#fixme 
{
     /* IE5.5+/Win - this is more specific than the IE 5.0 version */
    position:absolute;
filter:alpha(opacity=70);-moz-opacity:.70;opacity:.70;
height:100%;
width:100%;
visibility: hidden;
z-index:100;
left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
  	top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
vertical-align:middle;
text-align:center;
background-color:#000000; 
border-color:#ffffff;
border-width:0px; 
border-style:solid;
padding-left:7px; 
padding-right:7px;
}
body > div#fixme
{ 
position: fixed;
margin: auto;
top:0px;
left:0px;	
}

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.