nezbo Posted July 15, 2008 Share Posted July 15, 2008 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' ); } Quote Link to comment https://forums.phpfreaks.com/topic/114812-centre-div/ Share on other sites More sharing options...
ToonMariner Posted July 15, 2008 Share Posted July 15, 2008 remove the left and right properties (and remember expression is only understood by IE). just use margin: 0 auto; Quote Link to comment https://forums.phpfreaks.com/topic/114812-centre-div/#findComment-591093 Share on other sites More sharing options...
haku Posted July 15, 2008 Share Posted July 15, 2008 You will also need to remove position:absolute when doing what the toon mariner said. Quote Link to comment https://forums.phpfreaks.com/topic/114812-centre-div/#findComment-591109 Share on other sites More sharing options...
nezbo Posted July 16, 2008 Author Share Posted July 16, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/114812-centre-div/#findComment-591355 Share on other sites More sharing options...
nezbo Posted July 16, 2008 Author Share Posted July 16, 2008 here is the link that does what i want it to do... http://www.eastlancsmedicalservices.co.uk/dental.php if you click on any of the directions to it shows like i light box effect... Quote Link to comment https://forums.phpfreaks.com/topic/114812-centre-div/#findComment-591357 Share on other sites More sharing options...
nezbo Posted July 16, 2008 Author Share Posted July 16, 2008 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; } Quote Link to comment https://forums.phpfreaks.com/topic/114812-centre-div/#findComment-591369 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.