visitor Posted November 10, 2009 Share Posted November 10, 2009 Hi, I've been told that to centre something I have to do this... to simply add a div wrapper around the entire slideshow code and center it using margin auto. <div id="slideshow-wrapper"> --all the slideshow code goes here-- </div> Example: If the slideshow overall width is 600 pixels, then you would give that div the following css: #slideshow-wrapper {width: 600px; margin: 0 auto;} unfortunately this doesn't work. Has anyone got another idea how to centre things? Thanks Link to comment https://forums.phpfreaks.com/topic/181018-how-to-centre-something/ Share on other sites More sharing options...
merylvingien Posted November 11, 2009 Share Posted November 11, 2009 div#slideshow-wrapper { height:auto; margin:auto; position:relative; width:600px; } Try that! Link to comment https://forums.phpfreaks.com/topic/181018-how-to-centre-something/#findComment-955319 Share on other sites More sharing options...
haku Posted November 11, 2009 Share Posted November 11, 2009 Is your wrapper absolutely positioned? If so, the margins won't work. Link to comment https://forums.phpfreaks.com/topic/181018-how-to-centre-something/#findComment-955340 Share on other sites More sharing options...
visitor Posted November 11, 2009 Author Share Posted November 11, 2009 Hi, Thanks for your suggestions...! Unfortunately some contents are positioned absolutely. I think that's the reason why the "div slideshow-wrapper" doesn't work. visitor Link to comment https://forums.phpfreaks.com/topic/181018-how-to-centre-something/#findComment-955795 Share on other sites More sharing options...
visitor Posted November 21, 2009 Author Share Posted November 21, 2009 Hi Has anyone got an idea why I can't centre this one, please...? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>test</title> <style type="text/css"> div#slideshow-wrapper { height:auto; margin:auto; position:relative; width:512px; } </style> </head> <body> <div id="slideshow-wrapper"><img src="ip0001-001.jpg" width="512px" height="384px"></div> </body> </html> thanks visitor Link to comment https://forums.phpfreaks.com/topic/181018-how-to-centre-something/#findComment-962437 Share on other sites More sharing options...
haku Posted November 22, 2009 Share Posted November 22, 2009 I already told you why: Is your wrapper absolutely positioned? If so, the margins won't work. Link to comment https://forums.phpfreaks.com/topic/181018-how-to-centre-something/#findComment-962915 Share on other sites More sharing options...
FaT3oYCG Posted November 22, 2009 Share Posted November 22, 2009 the solution is to not use absloute positioning on any main elements but simply position the elements within a main div and make those specific elemnts positions absolute instead allowing you to still have relativley positioned content on your page. Link to comment https://forums.phpfreaks.com/topic/181018-how-to-centre-something/#findComment-963086 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.