Click to See Complete Forum and Search --> : align doesn't work
Hellusius
09-21-2006, 10:24 PM
I made a CSS class
.backgroundlayer {
height: 100%;
width: 800;
background-color: #EFDFC9;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
text-align: center;
text-vertical-align: top;
}
And all other site content is within this table class, but the align doesn't seem to work.
Am I doign something wrong?
toicontien
09-21-2006, 11:12 PM
The text-align property only applies to inline tags, like b, i, span, strong, a, and text. If you want to center block elements or tables, you have to use auto left and right margins:
body {
text-align: center; /* For IE5-Win */
}
#wrapper {
margin: 0 auto;
text-align: left;
width: 770px;
}
<div id="wrapper">
<!-- Page content goes here -->
</div>
The text-vertical-align property is an invalid CSS property. The vertical-align property is valid and aligns things vertically in two cases:
1) vertical-align is applied to a TD tag. It vertically aligns all content within the table cell.
2) vertical-align is applied to an inline element: It vertically aligns that inline element in the line-box in which it exists. Basically, it vertically aligns the tag with respect to the line of text.
And that's it. Vertical-align doesn't work on anything else or in any other situation.
What are you trying to achieve?
mark_yieh
09-22-2006, 12:38 AM
I disagree with toicentien. Text-align does work for block level elements. As a matter of fact, it only works for block level elements. Inline elements will only be as large as the content it contains, therefore there is no need to use text-align for inline elements. the thing to remember when using text-align is to put it in the parent element. For example:
<div style="width: 500px; text-align: center;">
<p>This paragraph is going to be aligned center.</p>
</div>
vertical-align is the same thing as text-align except for the vertical aspect. And it's vertical-align, not text-vertical-align.
Just by looking at that one css rule, I can't tell if you're doing anything wrong. i have to see the rest of the css and the html.
felgall
09-22-2006, 12:59 AM
text-align only works for text. If you want to align anything other than text you need to use margin:auto for centring and float:left and float:right to align to the left and right respectively. In all cases these only applies to block elements.
Hellusius
09-22-2006, 06:01 AM
well I just tried using <center> in html before I declare the table with the class, btu that doesn't seem to work either, really odd.
and another question, can I preset the values of the TD within each class?
Hellusius
09-22-2006, 06:05 AM
If you want to see the website click here (http://warnicro.awardspace.com/portofolio/index.php)
Hellusius
09-22-2006, 12:19 PM
suggestions?
ray326
09-22-2006, 01:03 PM
Text-align does work for block level elements. As a matter of fact, it only works for block level elements.Text-align doesn't work ON block elements, it works on the CONTENT of the block element to which it applies. (Assuming we're talking about web browsers and not IE.)
ray326
09-22-2006, 01:08 PM
What is it exactly that isn't centered that is supposed to be? If it's the whole content area then change the margin to margin: 0 auto; in that class.
Hellusius
09-22-2006, 01:47 PM
well the whole brown piece from top to bottom of the screen should be centered instead of on the left side of the screen.
ray326
09-22-2006, 08:05 PM
Ok then what I said works for that aspect of it.