I made box and I set line-height, the text is automatically vertically center. Is there a way or any kind of trick to set the text on the bottom of the box?
div {
width: 100px;
height: 100px;
background: #eee;
color: #333;
text-align: center;
line-height: 100px;
vertical-align: text-bottom;
}
<div>FoxRox</div>
You could set display to table-cell, try this CSS for example.
Demo: http://jsfiddle.net/Kawwr/
Setting the
height
of the div and theline-height
of the text to the same value, 100px in your case, is a method of vertically centering the text within the div. That's the problem.Changed
line-height
and removed uselessvertical-align
=> it's displayed at the bottom now http://dabblet.com/gist/2790000You could check out my answer to https://stackoverflow.com/a/6116514/682480.
Here is the demo for the above answer.
The trick is to use
display: table-cell
on the outer container. That way you can use thevertical-align: bottom
anddisplay: inline-block;
on the div.Enclose the text in a
p
tag withdisplay:inline-block
. Setvertical-align
to thep
element.Demo