Vertical-align in UL LI?
15,208
Solution 1
the text is aligned with respect to its line height so either you go through increasing line height and then applying vertical align
or
using padding-top
you can check this link for reference
or
http://www.w3schools.com/cssref/pr_pos_vertical-align.asp
Solution 2
you can use vertical-align
with display:table-cell
.more {
background-color: red;
height: 50px;
display:table-cell;
vertical-align:middle;
}
.moretwo {
background-color: green;
height: 50px;
display:table-cell;
vertical-align:sub;
}
Author by
Ron Corazon
Updated on June 04, 2022Comments
-
Ron Corazon almost 2 years
<ul> <li class="more">aaa</li> <li class="moretwo">aaa</li> <li class="more">aaa</li> </ul> .more { background-color: red; height: 50px; vertical-align:middle; } .moretwo { background-color: green; height: 50px; vertical-align:sub; }
Why in this example vertical align doesn't working? Is possible to make? If yes, how can i make it?
LIVE EXAMPLE: http://jsfiddle.net/gQM68/ with yours answers
-
Dennis Traub over 12 yearsWorks for me (FF3). Which browser are you using?
-
Anton over 12 yearsmust read this developer.mozilla.org/en/CSS/…
-
Anton over 12 yearswhy you want to use
sub
usevertcal-align:bottom
instead, also why you have usedspan
?? see jsfiddle.net/gQM68/3 -
My Head Hurts over 12 yearsThis will never vertically align anything. I don't downvote, but if I did, this would be one.