FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

[resolved] Body alignment

 


riv
My problem is that I want my site to be aligned center. I know how to do this, but I'm having some troubles doing it. I have a "container" div, and I have "body {text-align: center;}" and "#container {text-align: center;}." I have done this before so my guess is that I have done something wrong or missed something. The HTML file is located here, and the CSS file is located here.

Any help is greatly appreciated.


Last edited by riv on Sun Mar 05, 2006 8:57 pm; edited 1 time in total
DoctorBeaver
It looks to me as if you've got text-align: justify; in the container
riv
I know that; I want the text to be justified, but I want the container to be in the center. Like this
SystemWisdom
Centering text in CSS is done with text-align, but not for structural elements. There are of course ways to trick whatever browser you're targetting, but the best way to center stuff like "container" div's is to use margins like:

Code:

<html>
<head>
<style><!--
#container
{
    display: block;
    width: 400px;
    height: 400px;
    margin: 0 auto;
    background: #345;
    border: 1px dashed #89A;
}

#containee
{
    display: block;
    width: 200px;
    height: 400px;
    margin: 0 auto;
    background: #89A;
    border: 1px dashed #345;
    text-align: justify;
}
--></style>
</head>
<body>

<div id="container">
 <div id="containee">
  <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam nisl. Nam velit. Vestibulum commodo porttitor orci. Donec scelerisque ipsum eget erat luctus egestas. Cras metus dui, condimentum et, iaculis at, hendrerit vitae, justo. Aenean lobortis diam vitae turpis. Nam lacus erat, bibendum quis, ultricies quis, scelerisque sed, nunc. Nulla facilisi. Donec mattis, nulla id feugiat semper, odio nibh mollis risus, sed dignissim risus erat vitae dui. Aenean ligula sapien, aliquam eu, pellentesque quis, pharetra quis, velit. Ut eu enim non augue sodales facilisis.</p>
 </div>
</div>

</body>
</html>
DoctorBeaver
riv - I was merely commenting on the fact that in your 1st post you said you've got #container {text-align: center;} when in fact you've got #container {text-align: justify}
riv
Thanks; the margin trick now aligns everything center.
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.