I would like to know to align the text in a p
element to be vertically centered.
Here are my styles:
In my case margin auto works fine.
p {
font: 22px/24px Ubuntu;
margin:auto 0px;
}
If you use Bootstrap, try to assign margin-bottom 0 to the paragraph and after assign the property align-items-center to container, for example, like this:
<div class="row align-items-center">
<p class="col-sm-1 mb-0">
....
</p>
</div>
Bootstrap by default assign a calculate margin bottom, so mb-0 disabled this.
I hope it helps
Alternative solution which scales for multi-line text:
Set vertical and horizontal padding to be (height - line-height) / 2
p.event_desc {
font: bold 12px "Helvetica Neue", Helvetica, Arial, sans-serif;
line-height: 14px;
padding: 10.5px 0;
margin: 0px;
}