knystrom18 Posted December 20, 2009 Share Posted December 20, 2009 I have no idea why this refuses to center. <!DOCTYPE HTML><html lang="en"><head><link rel="shortcut icon" href="images/shortIcon.jpg" /><link rel="stylesheet" type="text/css" href="css/divs.css" /><link rel="stylesheet" type="text/css" href="css/general.css" /><link rel="stylesheet" type="text/css" href="css/content.css" /><link rel="stylesheet" type="text/css" href="css/links.css" /><title>Kyle's Portfolio » Home</title></head><body> <div class="center"> <div id="shadows"> <div id="allContain"> <header> <a href="index.html"><img src="images/banner.jpg" alt="« Back Home" /></a> </header> </div><!--allContain--> </div><!--shadows--> </div><!--center--></body></html> The accompanying css: @charset "utf-8";/* divs.css */.center { border: solid 5px #f00; margin: 0px 0px 0px 0px; background-image: url(../images/backgrounds/stripe.png); background-repeat: repeat; text-align: center;}#shadows { border: solid 1px #fff; background-color: #000; /*still need to make background image*/ width: 900px;}#allContain { border: solid 1px #fff; margin-left: 20px; margin-right: 20px;} Thanks! Link to comment Share on other sites More sharing options...
Ingolme Posted December 21, 2009 Share Posted December 21, 2009 Try applying "margin: auto;" to the #shadows selector. Link to comment Share on other sites More sharing options...
knystrom18 Posted December 21, 2009 Author Share Posted December 21, 2009 Try applying "margin: auto;" to the #shadows selector.You sir... are a GENIUS. You've blown my mind. Thanks, that was driving me crazy. Link to comment Share on other sites More sharing options...
Ingolme Posted December 21, 2009 Share Posted December 21, 2009 text-align only centers text within an element. If you apply "auto" to the margin of an element with a fixed width, it will put an equal margin on each side, which will center it. Link to comment Share on other sites More sharing options...
knystrom18 Posted December 21, 2009 Author Share Posted December 21, 2009 Will that method work for liquid layouts as well? Link to comment Share on other sites More sharing options...
Ingolme Posted December 21, 2009 Share Posted December 21, 2009 Will that method work for liquid layouts as well?It will work on any element that doesn't already take the full width of the screen. Link to comment Share on other sites More sharing options...
knystrom18 Posted December 27, 2009 Author Share Posted December 27, 2009 That is fantastic, thank you. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.