There is a code:
<div style="background: #000; width: 100px; height: 30px; color: #fff; text-align: center">text</div>
How to make the word text recede from above and stand exactly in the middle. padding not to offer .
as an option to add line-height: 1.8
<div style="background: #000; width: 100px; height: 30px; color: #fff; text-align: center; line-height: 1.8">text</div>
Alternatively, use
position:relative
and
top:-...px
Or just negative mergin.
line-height:
should be equal to the height of your block, i.e. 30px
.
display: table-cell;
vertical-align: middle;
Source: https://ru.stackoverflow.com/questions/152269/
All Articles