HTML - Centering Div Layout
I am working on a website, and I have been trying to center the homepage so that it looks the same on every computer/ browser. It's sort of set up as a juvenile div layout. I've been using other layouts as an example so I don't really know how to fix what I don't want from theirs. I'd like the main image to be centered but I can't figure it out. It's positioned absolutely which might be part of the problem but I don't know what else to set it as.
Also, on top of centering the image horizontally, I was wondering if there was any way that I could position it in the very center of the page. The link is http://appleseatmoregrass.webs.com/index.htm Similar TutorialsI have a website and I used css to make my Div tags set to absolute. The only problem is that when you open it in a browser, the browser won't open big enough and wil block out some of my content (forcing me to scroll to the left or maximize the borswer to see the whole page) . How do i make the divs always appear in the center of the page always. Also how do i make it so when you change the siz of the browser my divs will change with it to remain in the center. I tried doing the margin auto trick but it still doesn't work. Here is my stle sheet code and the web page html code... any help would be appreciated. /* CSS Document */ #wrapper {margin-right: auto; margin-left: auto; margin-top: 20px; margin-bottom: 0;;} body { margin : 0px 0px 0px 0px; background-color: #E1AE5A; background-repeat: repeat; } #top { position: absolute; height: 48px; width: 900px; left: 250px; top:3px; border:0px none; z-index:1; color: #000033; } #main { position: absolute; top: 542px; left: 328px; z-index:5; width: 745px; color: #FFFFFF; height: 28px; } #flash { position: absolute; top: 130px; left: 299px; z-index:4; width: 803px; color: #FFFFFF; height: 419px; } .style1 { font-family: Eurostile; color: #FFFFFF; } .style2 { font-family: Helvetica; } #Layer1 { position:absolute; left:300px; top:121px; width:804px; height:540px; z-index:3; background-color: #000033; border: medium solid #FFFFFF; } .style3 { font-family: Eurostile; } #Layer2 { position:absolute; left:111px; top:170px; width:71px; height:124px; z-index:4; } .style4 {color: #000000} #Layer3 { position:absolute; left:482px; top:72px; width:37px; height:56px; z-index:2; } #Layer4 { position:absolute; left:652px; top:72px; width:24px; height:31px; z-index:2; } #Layer5 { position:absolute; left:822px; top:72px; width:84px; height:58px; z-index:2; } #Layer6 { position:absolute; left:992px; top:72px; width:95px; height:50px; z-index:2; } #Layer7 { position:absolute; left:331px; top:139px; width:750px; height:446px; z-index:9; } #Layer11 { position:absolute; left:319px; top:72px; width:12px; height:10px; z-index: 2; } #Layer8 { position:absolute; left:302px; top:98px; width:791px; height:48px; z-index:10; } #Layer9 { position:absolute; left:299px; top:40px; width:32px; height:20px; z-index:0; } #Layer10 { position:absolute; left:1016px; top:595px; width:24px; height:26px; z-index:10; } and the html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" land="en"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="styles.css" rel="stylesheet" type="text/css"> </head> <body> <div id="top"> <h1 align="center" class="style3 style4">on The side, Inc. </h1> <p align="center" class="style3"> </p> </div> <div class="style2 style3" id="main">on The side is a value added promotional marketing organization focused on working with companies to make them more market-facing. We take time to learn about our clients' business model, industry and previous marketing agendas before taking a next step OR leap - if necessary.</div> <div id="Layer1"></div> <div id="flash" align="center"> <object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="425" height="400"> <param name="movie" value="main.swf"> <param name="quality" value="high"> <embed src="main.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="425" height="400"></embed> </object> </div> <div id="Layer3"><a href="who.html"><img src="who.jpg" width="100" height="70" border="0"></a></div> <div id="Layer4"><a href="what.html"><img src="what.jpg" width="100" height="70" border="0"></a></div> <div id="Layer5"><a href="ideas.html"><img src="ideas.jpg" width="100" height="70" border="0"></a></div> <div id="Layer6"><a href="why.html"><img src="why.jpg" width="100" height="70" border="0"></a></div> </body> </html> so what is the easiest and best way to center a div within a div? or a div within anything else for that matter. How do you center vertically? and How do you venter horizontally? how can i center the nav on this page? http://fantasyfootball.pzproductions.com/testing Right now I'm having a bit of an issue with my website. As you see here I'm using a series of div boxes but they all stay in a fixed location. I was wondering how to get the whole thing centered. Thanks. I have a page that is not being centered on the background in both IE 6&7 but looks perfect in FF. I am not sure what is wrong because the template I used is vaild Here is the page http://www.mesquitechristmas.com/wea...Z119&icao=KHQZ I have been banging my head all day an maybe just need another pair of eyes. -Thanks I just noticed that the site I coded is not centered but is aligned to the left on resolutions larger than 1024x768. Is there a way to fix this? Here is the css for the main div which has all the content. #container { position:absolute; left:0px; top:0px; width:1002px; height:auto; margin:0px auto; border:0; padding:0; My site is working correctly in bot Safari & FF but I can't seem to get it to center in IE7. In Safari and FF, the content is centered and the window can be shrunk down to 1000px without scrollbars appearing (which is what I want). In IE7 its all sliding to the right and scrollbars are appearing at 1150px or something like that (which is what I want definitely don't want). This template is a little bit problematic because the background image for the blue area extends outside the central column on the left side and I need it to disappear when the window width is shrunk. I hope that makes sense. I can't figure out an alternative solution that works in IE7, any ideas? Check out the template in question at: http://current-post.com Hello, I'm having real trouble aligning images to the 'exact' centre in different browsers. I'm using <div align="middle"> </div> around the whole code at the moment, which aligns horizontally in Chrome and Firefox, but not IE9. But even this does not vertically align as well. Afraid I don't know much about CSS or any other div tags. I built the site in Dreamweaver - this is the code straight from site: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <div align="middle"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>www.test.com</title> <style type="text/css"> <!-- body { background-color: #000; } --> </style></head> <body> <img src="comet3.jpg" width="933" height="658" border="0" align="middle" usemap="#Map" /> <map name="Map" id="Map"><area shape="circle" coords="885,123,9" href="comet2.html" /><area shape="circle" coords="916,124,9" href="comet4.html" /><area shape="rect" coords="785,71,904,103" href="contact.html" /><area shape="rect" coords="665,70,756,109" href="about.html" /> <area shape="rect" coords="371,73,462,112" href="index.html" /> <area shape="rect" coords="499,70,632,111" href="portfolio.html" /> <area shape="poly" coords="891,118" href="#" /> </map> </body> </html> </div> Really need some help with this! Thanks for any assistance Cheers J Hello, I wont call myself a website designer, but I do design my own websites. My problem is my website is only centered when monitor setting is at 1024 x 768. If an outside viewer with different monitor settings views my sites it will be really off-centered. I design all my websites in photoshop then code them with macromedia. Is their a code I could include into the html to keep my webpages centered no matter what size screen is viewing? Would appreciate any comments, JJ Is it possible to center links using the link tags itself: something like <a href align:center > Please help me with the following. This is not a problem in Firefox; only in IE. I am having trouble centering one DIV with a DIV to the left of the centered DIV. The DIV that is blue I would like centered according to the browser width and the red DIV I would like the same vertically as the blue DIV only left justified. In Firefox this works correctly the way I would expect. In IE the left justified div appears "pushes" the DIV ( in blue ) that I want centered further to the right; making it un-centered. thanks for any assistance. Code: <div width="100%"> <div align = "left" style="width:200px;float:left;background-color:#ff0000;"> <p style="font-size: 8pt;">This needs to be left justified........</p> <p style="font-size: 8pt;">This needs to be left justified........</p> <p style="font-size: 8pt;">This needs to be left justified........</p> </div> <div align="center" style="background-color:#00ff00;"> <div style="width: 500px;background-color:#0000ff;"> <p style="font-size: 8pt;">this needs to be centered.................................................................................. </p> <p style="font-size: 8pt;">this needs to be centered.................................................................................. </p> <p style="font-size: 8pt;">this needs to be centered.................................................................................. </p> <p style="font-size: 8pt;">this needs to be centered </p> </div> </div> I am trying to center some text in a table, but horizontally only. It centers vertically inside a cell in a table when i use either of these tags. HTML Code: <h2 style="text-align:center"> <center>text</center> How do i fix this? I clarified what i want in the attatched picture. I would like to center three button images under an image. In the old day we would put our text into the image and create a two-row table, with the top row having one cell three columns wide and the bottom row having three cells. I have tried making my image with three uls with background images under them, but of course I can't force the full image to show since my content doesn't take up the full space. I am currently putting things in a table, just to make the full image show, but I feel like I'm still doing things old-school. Is there a newer, spiffier way to do this? table { width:780px; font-size:125%; padding:0; overflow:hidden; } td { width:254px; height:60px; background-repeat:no-repeat; background-position:top left; background-image:url(images/navbackground2.png); padding:0 0 0 20px; } Also my images won't justify. The space between the cells seems predetermined no matter what I futz with and there's a space to the right of the last image that I don't want. Finally, is there a way to put all three background statements into one code? (I know that's a CSS question, but I don't want to cross-post.) Elisabeth Hi, Have just uploaded a new website. In Safari, Opera and Firefox the webpage floats in the middle of the browser page, as I want it to. In some versions of IE its sits to the far left. Here is the page: http://www.ironworksstudio.co.uk/ And here is the CSS: Code: *{ margin: 0; padding: 0; } body{ font-family: Helvetica, Verdana, Arial, sans-serif; font-size: 15px; color: #000000; background-color:#000000; } #container { margin-right: auto; margin-left: auto; margin-top: 15px; width: 700px; background-color:#000000; } p{ padding-top: 10px; font-size: 13px; line-height: 18px; } #header { margin-right: auto; margin-left: auto; margin-bottom: 0; height: 100px; width:700px; background-color:#000000; padding: 0 0 10px 0; } #menu ul{ margin-left:0; font-family: Helvetica, Arial, sans-serif; font-size: 14px; background-color:#FFFFFF; } #menu li{ text-align: center; text-decoration: none; color: #ffffff; background-color: #000000; list-style-type: none; width: 84px; height: 20px; padding-left: 5px; padding-right: 5px; padding-top: 5px; padding-bottom; 3px; margin-right: 2px; margin-left: 2px; float: left; border: 1px solid; } #menu li:hover { color: #ffffff; background-color: #333333; } #menu li a { text-decoration: none; color: #ffffff; } #menu li a:hover { color: #ffffff; } #footer { font-size:12px; font-family: Helvetica, Arial, sans-serif; width: 700px; margin-right: auto; margin-left: auto; clear: both; background-color:#000; color: #FFF; } #top_image { margin-bottom:20px; clear: left; background-color:#000000; } #menu { float: left; width: 700px; margin-bottom:10px; background-color:#000000; } #two_column { font-size:12px; font-family: Helvetica, Arial, sans-serif; line-height:1.4; margin-top: 10px; margin-bottom: 50px; float: left; width: 700px; text-align: left; background-color:#000; } #l_column { font-size:12px; font-family: Helvetica, Arial, sans-serif; color:#FFF; line-height:1.4; margin-top: 10px; margin-right: 30px; margin-bottom: 50px; float: left; width: 335px; text-align: left; background-color:#000; } #l_column a{color:999999;} #r_column { font-size:12px; font-family: Helvetica, Arial, sans-serif; color:#fff; line-height:1.4; margin-top: 23px; float: right; width: 335px; background-color:#000; padding: 0 0 10px 0; } .left { font-size:12px; font-family: Helvetica, Arial, sans-serif; width: 335px; float: left; text-align: left; border: 2px solid #000000; border-collapse: collapse; background-color:#000000; } .right { font-size:12px; font-family: Helvetica, Arial, sans-serif; width: 335px; float: right; text-align: left; border: 2px solid #000000; border-collapse: collapse; margin-top:12px; background-color:#000000; } th { font-weight: bold; font-size:13px; color: #000000; background-color:#FFFFFF; padding: 5px; } td { padding:5px; } tr { color:#FFFFFF; } .rowstyle1 { border-bottom:1px dotted; } #gallery { background-color:#000; width: 680px; padding-left: 0; } #gallery ul { list-style: none; margin-left: 0; } #gallery li { padding-left:1.2px; } #gallery ul li { display: inline; padding-right: 0; } #gallery ul img { border: 0; border-width: 0; } #gallery ul a:hover img { border: 0 solid; } #gallery ul a:hover { color: #cccccc; } hr {color:#333333; border-style:normal; padding: 0 0 0 0; margin: 0 0 10 0; } h2 {color:#ffffff;} </style> Take a look at this image. What I want to do is make the background black (which I know how to do), but to add in the black header plus the gray box--same width. What I'm trying to do is my forum is fixed width (in the center, not expanded on browser) and I want to do the same to a new non-forum site starting from scratch. I know I must have an open command somewhere on <center> or something but I don't want the whole body of this to be centered - only the title and name of the author. I've looked at it several times and can't figure it out. http://www.bestsellersworld.com/watson-swing.htm Can someone tell me how to do this? I have a page laid out, but its not centering the main table? All the contents should be centered on the page but its shoved to the left. Take a look he www.puliz.com/default2.htm Also, there is a gap in the graphics just below the image map that I have placed there. Any ideas? Thanks in advance! Scott I know some HTML but not a lot. I'm working on an HTML version of my companies website (it's currently in flash.) I'm happy with the design right now but I can'ty seem to find a way to center all of the contents of the page. Any help would be very much appreciated. http://www.ars-guardian.com/htmlhome.html Hi. I can't remember how to center a table to the center of the page. Here is my current code: HTML Code: <table style="width: 66%" > <tr> <td class="style4"> <a href="http://au.youtube.com/user/bombardieraddict123" style="color:white" class="style5"> Bombardieraddict123</a></td> </tr> <tr> <td style="background-color:white">More Information Will go here</td> </tr> </table> I want it to be centered in the middlof thepage. How can I do that? thanks |