Reputation: 5216
I am trying to achieve the following alignments in css with minimal css elements:
Middle:
==============================================================
= [icon] =
= [ ] Text =
= [ ] =
==============================================================
Bottom:
==============================================================
= [icon] =
= [ ] =
= [ ] Text =
==============================================================
Right Middle:
==============================================================
= [ ] =
= Text [ ] =
= [ ] =
==============================================================
Right Bottom:
==============================================================
= [ ] =
= [ ] =
= Text [ ] =
==============================================================
Middle is REALLY easy:
Assume text line-height = 10px, icon height = 30px
<div class="container">
Text
</div>
<div class="container right">
Text
</div>
.container {
line-height: 30px;
background: url(...) no-repeat center left
padding-left: 38px;
}
.container.right {
line-height: 30px;
background: url(...) no-repeat center right
padding-right: 38px;
}
The question is: How do I do the bottom alignment?
Upvotes: 2
Views: 20311
Reputation: 1515
The only way you can align elements vertically from the parent element is by setting it to display as a table-cell with display:table-cell;
and vertical-align:
. If that isn't acceptable, you must do it from child elements and relative positioning.
Upvotes: 5
Reputation: 2462
Its not a big deal I think. First set the background image position to top left and then increase the line height according to your image height.
For right aligning the section, I set text-align:right;
also.
Hope you are trying to do this.
Upvotes: 1