Working Code: https://jsfiddle.net/vwdhd1wy/4/
For 1. Vertical align two glyphicons and texts to middle. (vertical align middle doesn't work).
You can really tidy up the CSS as you don't want repeated code. Add vertical-align: top;
to all span elements to ensure they are all starting at the same position as inline-block elements next to each other can get messy depending on their contents.
There is some inherited code for .glyphicon
which is setting line-height: 1
and top: 1px;
so you need to override this with div > span.glyphicon { line-height: 30px; top: 0px; }
. The rest is just setting height: 30px;
and the line-height: 30px;
(line-height for placing it in the middle).
div > span {
display: inline-block;
vertical-align: top;
}
div > span, div > span.glyphicon {
height: 30px;
line-height: 30px;
top: 0px;
}
.left, .right {
background-color: red;
}
.middle {
background-color: grey;
}
For 2. Modify css to have a small gap between text "thanks" and glyphicons to become something like instead of
As @ryantdecker said, remove the whitespace after all the span elements to remove the extra space that's showing. You get this whitespace due to it being treated as an "inline" (text) element when set to inline-block so whenever there is a space between inline elements, it also includes that when rendering the HTML.
Solution:
<span class="left glyphicon glyphicon-forward"></span><span class="middle">Thansk</span><span class="right glyphicon glyphicon-backward"></span>