3

My menu with icons looks like,

enter image description here

Icons are displayed slightly above the text caption. I read the tips given here, to use vertical-align. And after specifying both line-height and vertical-align, it doesn't have any effect.

Plunker code is here.

How can i ensure the icon and the text item are vertically aligned?

Community
  • 1
  • 1

3 Answers3

2

Try centering your icons within your em elements via the background-position property, which should cause them to be centered just as your caption text were and align properly (previously they were positioned in the top-left corner) :

em[class^='icon-'] {
   /* omitted for brevity */
   background-position: center; 
}

You can see an updated Plunker here and an example of what it looks like below ;

enter image description here

Rion Williams
  • 72,294
  • 36
  • 192
  • 318
1

Your icons are background images on a 50px square element. Just set the background to be centered

 em[class^='icon-'] {
   display: inline-block;
   height: 50px;
   width: 50px;
   background-repeat: no-repeat;
   vertical-align : middle;
   line-height:50px;
   background-position: center; /* <--- this part */
 }
Joseph Marikle
  • 72,900
  • 16
  • 109
  • 126
0

You can use a em {margin-top:10px;} and see when you want the icon and change the value of margin-top

wiredniko
  • 2,261
  • 3
  • 18
  • 34