PDA

View Full Version : Resolved Center aligning???



DarkLightA
Jun 25th, 2009, 04:05 PM
I'm trying to make the entire layout of my site centered:





<head>
<style type="text/css">
body {
text-align: center;
background-color: #CCCCCC;
}

#b {
background-color: #EEEEEE;
width: 693px;
text-align: center;
}

#a {
text-align: center;
}
</style>

</head>

<body>
<p><img src="images/me.jpg" /></p>
<div id="a"><div id="b"><p>hello</p></div></div>

</body>

</html>



But the "block" that both div a and b are focussed on, doesn't center align... Only the text inside does. How do I make the entire paragraph horizontally centered, so it is in the middle of the browser?

jcdevelopment
Jun 25th, 2009, 04:39 PM
create a wrapper DIV.




<head>
<style type="text/css">
body {
background-color: #CCCCCC;
}

.wrapper {
width:1000px;
overflow:hidden;
margin:0 auto; /* This and the width centers it*/
}

#b {
background-color: #EEEEEE;
width: 693px;
text-align: center;
}

#a {
text-align: center;
}
</style>

</head>

<body>
<div class="wrapper">

<p><img src="images/me.jpg" /></p>
<div id="a"><div id="b"><p>hello</p></div></div>

</div>
</body>

</html>



Hopefully this is what your looking for.

DarkLightA
Jun 25th, 2009, 05:13 PM
Thanks perfect! Thanks!