I've got a html-structure like this:
<div class="campain">
<div class="campainText">
<a href="#"><h2>Ny app til iPhone og iPad</h2></a>
<a href="#"><h2>Tips og vinn</h2></a>
</div>
<div class="campainPicture">
Picture goes here
</div><div class="clear"></div>
</div>
And I'd like the campainText to be right-align. The css for this element is this:
font-family: 'Spinnaker', sans-serif;
font-size: 17px;
color: #FFFFFF;
background-color: #A2AD00;
display: table;
padding: 4px;
margin: 4px 4px 4px 4px;
text-decoration: none;
I know that the rest of the css is working. The problem is that the text is left-aligned if I include the table-option in the display-field. As soon as I remove this, it works as expected. Are there any workarounds for this, or do I have to use display: inline and <br />
tags?
HTML | <td> align Attribute left: It sets the text left-align. right: It sets the text right-align. center: It sets the text center-align.
Short answer: your text isn't centered because the elements are floated, and floated elements "shrink" to the content, even if it's a block level element.
To place an item at the top or bottom of its cell, insert the "VALIGN=" attribute within the code for that cell. To vertically align an entire row (e.g., placing all data in that row at the tops of the cells), insert the "VALIGN=" attribute within the code for that row.
Fiddle: http://jsfiddle.net/xbNCZ/
"Table + text-align:right
does not work", because a table element doesn't stretch to the full width by default. Add width:100%
to get the desired result.
Before / After setting width:100%
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With