...

View Full Version : aligning text vertically to center of list item



sackstein
08-04-2010, 09:15 PM
I have a list with a background as well as with a custom list background image. The problem is the the height of the image is larger then the normal bullet.

So when the text appears next to it it is at the bottom of the image when I want it to appear in teh center of it.

I cant seem to achieve this with margin, padding or vertical align.. what am i missing?

met
08-05-2010, 12:08 AM
li {
/* these 2 properties are needed */
display:table-cell;
vertical-align:middle;

/* for the example */
background:red;
padding:5px;
height:40px;
}


the above centers text within any element (li in this case) vertically.

it's also likely that any "line-height:" declarations are messing with the padding/margin values you are trying. See if my provided code does what you require

cools4u
08-06-2010, 12:21 PM
set the proper line height for list item and padding top or padding bottom option to align text vertically to the center, you can also set vertical align to middle if the line height is fixed...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum