CSS - Center Content Help Required
HI hope someone can help me with this its been driving me mad for a couple of days now.
Have desiged a site with css layout but I want to center it in a page so when I resize the browser window it will stay in the middle of the page. I know its a bit long winded but I would greatly appreciate the help. I've used the css sheet and html bellow Thanks ---------------------------css--------------------------------- body { text-align: center; background-color:#000000; } #container { margin-left: auto; margin-right: auto; width: 65em; text-align: left; } #pageContent { height: 100px; width: 100%; background-color:#000000; border:solid #000000 thin; } /*Headings*/ h1{ } h2{ font-size:16px; font-weight: bold; color:#ff0000; padding-left: 0em; } h3{ } /*Div id's*/ /* --------------------------------------------------title------------------------------------------------------- */ #title { position:absolute; width: 429px; height: 162px; left: 194px; top: 25px; z-index:1; } /* --------------------------------------------------titleImage------------------------------------------------------- */ #titleImage { position:absolute; width: 358px; height:180px; left: 670px; top: 7px; z-index:2; } /* --------------------------------------------------navLeft------------------------------------------------------ */ #navLeftContainer { position:absolute; top: 188px; left: 194px; width: 154px; height: 405px; background-color:#ffffff; z-index:3; } #navLeft { position:absolute; top: 2px; left: 3px; width: 145px; height: 395px; background-color:#FFFFFF; border: solid #cccccc 2px; overflow:auto; } /* #navLeft ul { list-style:none; padding-top: 0em; padding-left: 0em; } #navLeft li { padding-bottom: .2em; } #navLeft a { text-decoration:none; font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#999999; font-weight:800; } #navLeft a:hover { color:#ff0000; } /* --------------------------------------------------navTop------------------------------------------------------ */ #navTop { position:absolute; top: 188px; left: 346px; width: 670px; height: 24px; background-color:#000000; font-family: Arial, Helvetica, sans-serif; border: solid #ff0000 2px; overflow:hidden; z-index: 4; } #navcontainer { padding: 0; height: 22px; } #navcontainer ul { border: 0; margin: 0; padding: 0; list-style-type: none; text-align: center; } #navcontainer ul li { display: block; float: left; text-align: center; padding: 0; margin: 0; } #navcontainer ul li a { background: #000000; width: 223px; height: 24px; border-top: 0px solid #000000; border-left: 0px solid #000000; border-bottom: 0px solid #000000; border-right: px solid #000000; padding: 0; margin: 0 0 10px 0; color: #ffffff; text-decoration: none; display: block; text-align: center; font: normal 16px/18px Arial, Helvetica, "Lucida Sans Unicode", verdana, lucida, sans-serif; } #navcontainer ul li a:hover { color: #ffffff; background: #ff0000; } #navcontainer a:active { background: #c60; color: #fff; } #navcontainer li#active a { background: #c60; border: 1px solid #c60; color: #fff; } /* --------------------------------------------------navBargains-------------------------------------------------- */ #navBargainsContainer { position:absolute; top: 594px; left: 194px; width: 154px; height: 158px; background-color:#ffffff; z-index:5; } #navBargains { position:absolute; top: 0px; left:2px; width: 146px; height: 150px; background-color:#000000; font-family: Arial, Helvetica, sans-serif; border: solid #ff0000 2px; overflow:auto; padding-left: 0px; color: ff0000; } /* -----------------------------------------------------contents---------------------------------------------------- */ #contents { position: absolute; left: 348px; top: 217px; width: 672px; height: 535px; background-color: #FFFFFF; overflow:auto; z-index:6; } #triangle { position: absolute; right: 0px; bottom: 0px; z-index:7; } /* -----------------------------------------------------html------------------------------------------------------*/ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "(URL address blocked: See forum rules)"> <html xmlns="(URL address blocked: See forum rules)"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <link href="main.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <!-- ****************************************************title******************************************* **** --> <div id="title"> <img src="test/images/Dark-Logo.jpg" /> </div> <!-- ****************************************************titleImage************************************** ********* --> <div id="titleImage"> <img src="test/images/titleImage.jpg" width="353" height="180" /> </div> <!-- ****************************************************navLeft***************************************** **** --> <div id="navLeftContainer"> <div id="navLeft"> <h2>Menswear</h2> <ul> <li><a href="linked.htm">Jackets </a></li> <li><a href="linked.htm">Jeans</a></li> <li><a href="linked.htm">T-shirts</a></li> <li><a href="linked.htm">Polos</a></li> <li><a href="linked.htm">Jumpers</a></li> <li><a href="linked.htm">Hodies & Sweats</a></li> </ul> <h2>Womenswear</h2> <ul> <li><a href="linked.htm">Going out Tops </a></li> <li><a href="linked.htm">Day Tops</a></li> <li><a href="linked.htm">Shirts & Blouses</a></li> <li><a href="linked.htm">Jeans & Denim</a></li> <li><a href="linked.htm">Knitwear</a></li> <li><a href="linked.htm">Polos</a></li> </ul> </div> </div> <!-- ****************************************************navTop****************************************** **** --> <div id="navTop"> <div id="navcontainer"> <ul id="navlist"> <li id="active"> <li><a href="#" id="current">Menswear</a></li> <li><a href="#">Womenswear</a></li> <li><a href="#">Junior</a></li> </ul> </div> </div> <!-- ****************************************************navBargains************************************* **** --> <div id="navBargainsContainer"> <div id="navBargains"> <h2>Items in Focus</h2> <ul> <li id="active"><a href="#" id="current">Item one</a></li> <li><a href="#">Item two</a></li> <li><a href="#">Item three</a></li> <li><a href="#">Item four</a></li> </ul> </div> </div> <!-- ****************************************************contents**************************************** ***** --> <div id="contents"> <div id="triangle"> <img src="test/images/triangle.gif" width="55" height="55" /> </div> </div> </div> </body> </html> /* Links End */ Similar TutorialsHi All, I have the following layout. The problem I am having is when the "center" div has lots of text in it the text expands out of the "center" div. I would like the div to stretch with the content. Code: <div id="main"> <div id="mainTop"></div> <div id="mainContent"> <div id="left"></div> <div id="center"> Lots and lots of text goes here </div> <div id="right"></div> </div><!-- end of maincontent --> <div id="mainBottom"> <div id="left2"></div> <div id="center2"></div> <div id="right2"></div> </div> </div> CSS Code: html, body{ margin: 0px; padding: 0px; text-align: center; min-height: 100%;} div{ border: 1px solid black;} /* Hack for IE, Reset to 100% height */ html, body, #main, #mainContent, #left, #center, #right, #left2, #right2{ height: 100%; } #left, #center, #right{ height: 100%; } /* End IE Hack */ #main{ position: relative; width: 100%; min-height: 100%; } #mainTop{ margin: auto; position: relative; height: 210px; width: 850px; text-align: left; background-color: yellow; } #mainContent{ margin: auto; position: relative; min-height: 100%; width: 850px; text-align: left; } #left{ position: absolute; min-height: 100%; width: 79px; left: 0px; background-color: yellow; } #center{ border: 1px solid red; position: absolute; width: 696px; left: 79px; background-color: #dcdbdc; min-height: 100%; } #right{ position: absolute; left: 775px; width: 75px; background-color: yellow; } #mainBottom{ margin: auto; position: relative; min-height: 146px; width: 850px; text-align: left; } #left2{ position: absolute; min-height: 100%; width: 79px; left: 0px; background-color: yellow; } #center2{ border: 1px solid red; position: absolute; width: 696px; left: 79px; background-color: yellow; min-height: 100%; } #right2{ background-color: yellow; position: absolute; left: 775px; width: 75px; min-height: 100%; } Also shown he http://www.steudel.org/css/test.php The yellow divs represent images that border the content. The whole layout is supposed to be able to stretch vertically. I'm not sure why the text is not stretching the center div. TIA, Mark I need to center the contents of two divs in one of my sidebars. The page can be seen he http://dev.asbco.com I need to center the free quote image and also the tabbed section beneath it. Any help is greatly appreciated as I'm trying to launch this site by the end of the week. Thanks! Hi I'm having a bit of trouble with a DIV/CSS layout - 2 DIVs are inside a 100% height 100% width container DIV. The first (top) DIV is the content and the second (bottom) DIV being a 100% width 240px height footer DIV. I can make the footer stick to the bottom of the page and display fine no problem, however, I am having trouble getting the content div to fill only the area above the footer. If I specify a 100% height for it then it extends the entire height of the page and content disappears behind the footer. Plus, I want to absolutely center the content in the space above the footer, not the absolute center of the whole page, which is all i am acheiving with 100% height! Basically, I need the content DIV to extend 100% then subtract the 240px height of the footer - I suspect it's not wise to mix px and %, however. I have attached an image to help with my probably confusing explanation! I do have a workaround using tables, which I would ideally like to avoid, particularly as it does not support IE6/7 browsers. If a solution can be acheived which uses JavaScript to format the DIVs, then I am open to any suggestions anyone may have. Thanks R Hi guys, I recently redeseigned my site using CSS from tables. When the window (IE) was made smaller before, the content would stay put but you just wouldnt see it all (obviously cause now the window is smaller) but with CSS it dumps it at the very bottom of the screen and leaves my content area totally blank. Is there some way this can be fixed? Daragh I actually have two problems... Installing hte firebug plugin for firefox may ease helping me out... The problem is with http:// kthxbai2u<dot>com I cant for the life of me center the "content" div. I have tried every method I found on the first 4 pages of Google. The only thing I can think of is that it is inheriting something wierd or I am missing something simple... The second problem, I can't seem to make the left and right side bar expand to meet up with the footer wayy down at the bottom of the page. I want that div to make a column the whole way down. If anyone can help me out, it would be more than appreciated! Thanks I am using the following code how do I change it so that it would show up in the center of the brower window? Thanks Tim PHP Code: <div style="position: absolute; left: 0px; z-index: 1; top: 0px; align: center\"> <object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0 ,0\" width=\"544\" height=\"396\" id=\"cardio\" align=\"middle\"> <param name=\"allowScriptAccess\" value=\"sameDomain\" /> <param name=\"movie\" value=\"ads/cardio3.swf\" /> <param name=\"loop\" value=\"false\" /> <param name=\"quality\" value=\"high\" /> <param name=\"wmode\" value=\"transparent\" /> <param name=\"bgcolor\" value=\"#ffffff\" /> <embed src=\"ads/cardio3.swf\" loop=\"false\" quality=\"high\" wmode=\"transparent\" bgcolor=\"#ffffff\" width=\"544\" height=\"396\" name=\"cardio\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /> </object> </div> Hi there, I have a content glider script, but I have added it to a wrapper with a background image. The css is using a white background colour so when a new layer is glided up, it covers the one underneath it. However, I want the background to be transparent to show the background image underneath.... If I remove the white background, they layers become transparent and overlay each other, so you can see all text in the layers on top of each other making it impossible to read. Is there anyway I can make it so it has a transparent background, but so it will not show the content under the new slide? This is my CSS: PHP Code: .glidecontentwrapper{ position: relative; /* Do not change this value */ height: 230px; /* Set height to be able to contain height of largest content shown*/ overflow: hidden; } /* Total wrapper width: 350px+5px+5px=360px Or width of wrapper div itself plus any left and right CSS border and padding Adjust related containers below according to comments */ .glidecontent{ /*style for each glide content DIV within wrapper.*/ position: absolute; /* Do not change this value */ background: white; visibility: hidden; width: 330px; } /* Total glidecontent width: 330px+10px+10px=350px Or width of wrapper div itself (not counting wrapper border/padding) */ .glidecontenttoggler{ /*style for DIV used to contain toggler links. */ width: 360px; margin-top: 6px; text-align: center; /*How to align pagination links: "left", "center", or "right" background: white; /*always declare an explicit background color for fade effect to properly render in IE*/ } Any help would be great! Thanks. Hi I have put together a home page using code from around the web and adjusted it until I have something that I like I think. My home page uses some css for color and style but I want to repeat my menu throughout the site, and clean up the css but dont have a clue what to do. I am not sure I can do this but if I put up my code and home page template would someone look at it for me please? Thank you Tiler Heya everyone, The next item on my todo list is to work on a design for DynaSig with just CSS for layout rather than the current tables. I haven't used CSS to create a really complex template before and I am not sure where to start. I want it to look pretty much exactly the same as the original. So. What do I do first? What should I learn and complete first? I'm kinda stuck on this one, and I don't want it to get put on the back-burner. Thanks for ideas/tips/comments/help/whatever comp Hello All, First time poster here. I am pretty new to CSS and this is one of my first attempts so bear with me. On the page below the image on the right and footer are touching. I have tried adding a "margin-bottom" to the main content area and also a "margin-top" to the footer wrap but neither seem to work. Generally I want to put a space of roughly 15px between both. This issue arises on Firefox, Safari & Chrome. Seems to work fine in IE. www . kmsjoinery . com/wip/lamella.php Any help would be greatly appreciated. Hi Guys, Hope someone can help out here.. I am trying to create a page with a header and footer and a middle portion for the content. I am not used to using CSS and I thought I had it working but when I test in IE it doesn't quite work as expected.. The footer removes itself from the bottom of the page and the scrollbars for the maincontent extend below the footer.. You'll see what I mean if you open this in IE: http://www.modelglamorous.com/div_test.htm http://www.modelglamorous.com/css/mainstyle.css It works perfectly in Firefox but not in IE.. I think it's something simple but I am not sure how to fix it.. TIA, N. Please take a look at the following page. its a simple two column layout http://www.aptlogix.com/testcss.html I need to have both divs side by side of same height independent of the contents in them. how can i stretch the right yellow backgroudn to the full length of the page ?. the yellow color is displayed till the height of the page when i scroll the page the rest of the bottom is white. i have tried that min-height thing with it but no luck. Please advice Regards, DQ Hi, I have a site (URL address blocked: See forum rules) which I need the bottom footer bar to always be at the base of the screen (on larger resolutions). So when you start minising the browser window and adjusting it up and down it seems to have this grey space under the footer but the footer is meant to be flush to the bottom. Works on every other page bar the homepage and the problem only happens in IE7. Any ideas? Hi, i need a simple, clear and easy to understand explanation of the parameters given to the CSS 'clip' property. i understand what the clip property does in essence - basically clips a rectangle from the given image - but i do not understand how the points given to the rect() function work - i cannot visualise it. My book does not describe it very well and the websites i have visited dont either. Therefore id be grateful if someone could give me a simple explanation Thanks Hi all I'm just wondering if anyone can help me with a few corrections I need to make on a site I'm developing ? I've recently developed a site on Mac OS X and been viewing it using Firefox whilst working on it, the site should look like this : http://www.timetraveltours.net/firefox.jpg However when viewed in Safari I have found that there is a problem with the menu bar as seen here : http://www.timetraveltours.net/safari.jpg To add to that I have noticed that there is also a problem at the bottom of the page, as seen here : http://www.timetraveltours.net/explorer.jpg I'm guessing that I just have to change some of the positioning or something in the CSS but don't really want to it without some help/advice first incase I mess the whole thing up. The CSS code can be found here http://www.timetraveltours.net/base.css Other style sheets are : http://www.timetraveltours.net/ie5mac.css http://www.timetraveltours.net/ie5win.css http://www.timetraveltours.net/netscape.css http://www.timetraveltours.net/screen.css http://www.timetraveltours.net/style.css (if needed) I'm also wondering if these problems appear in 3 different browsers on a Mac what problems there are when viewed with various browsers on Windows and would very much appreciate anyone to beta test the site for me on the Windows platform. I hope that I have explained myself cleary and given the correct information ? Many thanks in advance The site can be found at : http://www.timetraveltours.net Hi, I recently started migrating from a table layout to a css based one. I've probably made the classic mistake of using IE to develop only to find it looks awful in other browsers e.g. firefox. Being relativity new to CSS I've looked at various websites and if I understand the issue correctly some browsers like firefox adhere strictly to the CSS standard whereas IE doesn't. My question is would I be better developing separate CSS files for each browser type and use a script to determine which one? If anyone can point me at a resource that points out the differences between IE CSS standards and other browsers I'll be internally grateful. Regards Paul Well I managed to find a partial solution by adding "clear" to the "statusDiv" like so: Code: .statusDiv { clear: both background-image: url(../png/disclosure_triangles/blue_block.png); height: 20px; margin-bottom: 1px; } This kicks sibling divs onto their own line (which is what I wanted) but the spacing between divs is 2 pixels and I can't seem to find any combination of padding, margins etc to get the spacing down to one pixel. Does anyone know of a way to control the inter-div spacing when "clear" is defined? Thanks Ken --------------------------------------------------------------- Original post --------------------------------------------------------------- I'm trying to make a few divs to create the same basic functionality as an outline (with disclosure triangles etc...) and am having alignment problems. The first row renders perfectly but the text of subsequent rows overlaps the text of first row. Here's the html: Code: <div id="contentBlock" class="bodyText"> <div class='statusDiv'> <div class='disclosureCollapsed'></div> <div class="disclosureDivLabel">New</div> </div> <div class='statusDiv'> <div class='disclosureCollapsed'></div> <div class="disclosureDivLabel">Open</div> </div> </div> And here's the CSS: Code: #contentBlock { position: absolute; top: 130px; left: 200px; height: 101%; /* Hack to force vertical scroll bars */ right: 280px; min-width: 400px; visibility: visible; display: block; } .statusDiv { clear: both background-image: url(../png/disclosure_triangles/blue_block.png); height: 20px; margin-bottom: 1px; } .disclosureCollapsed { background-image: url(../png/disclosure_triangles/blue_collapsed_wide.png); display: block; text-align: right; /*position: absolute;*/ float: left; top: 0px; left: 0px; width: 18px; height: 20px; } .disclosureCollapsed:hover { cursor: pointer; } How would I make the text in each subsequent row (statusDiv) line up? Thanks for any help Ken http://www.hybridillusions.com/wordpress/?m=200712 Still working on it, but something caught me and I'm clueless. See, I'm still learning Tableless CSS, and well... I'm not sure how to have it so that the content doesn't run over the footer like that. As it should be more like... http://www.hybridillusions.com/wordpress/ For CSS reference, here is where the css file is located: http://www.hybridillusions.com/wordpress/wp-content/themes/simplistic/style.css Thanks in advance! |