EDIT: Option with transform: translate
the advantage of it is that vc will not depend on fixed values, because it will always align in the center of the box, regardless of its height and width.
.box {
width: 200px;
height: 100px;
background-color: tomato;
position: relative;
}
.box span {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
<div class="box">
<span>Texto Item</span>
</div>
There are several options to center elements (horizontally and vertically). Without your code it is difficult to suggest the best option...
My suggestion, to be different from the others already answered, is to put the line-height
with the same value as height
box set
See the example below working:
.box {
width: 200px;
height: 100px;
background-color: aquamarine;
line-height: 100px;
text-align: center;
}
<div class="box">
<span>Texto Item</span>
</div>
Might help you "https://css-tricks.com/snippets/css/a-guide-to-flexbox/"
– Valdeir Psr