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
  • 74,820
  • 37
  • 200
  • 327
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
  • 76,418
  • 17
  • 112
  • 129
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,491
  • 3
  • 19
  • 37