absolute-positioned position: absolute + translate no limit to width & height
<style>
main{
width: 100%;
min-height: 152px;
display: flex;
}
main > span {
position: absolute;
top: 50%; left: 50%;
background: #b4a078;
color: white;
padding: .3em 1em .5em;
border-radius: 3px;
box-shadow: 0 0 .5em #b4a078;
transform: translate(-50%, -50%);
}
</style>
<main>
<span>¡Centro, por favor!</span>
</main>Ver resultadotable-like layout display: table/table-cell + vertical-align: middle no limit to width & height
<style>
main {
width: 100%;
height: 152px;
display: table;
}
main > div {
display: table-cell;
text-align: center;
vertical-align: middle;
}
main > div > span {
width: 50%;
background: #b4a078;
color: white;
padding: .3em 1em .5em;
border-radius: 3px;
box-shadow: 0 0 .5em #b4a078;
}
</style>
<main>
<div><span>¡Centro, por favor!</span></div>
</main>Ver resultado



Comentarios