absolute-positioned position: absolute limit the 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;
margin-top: -16px;
margin-left: -72px;
}
</style>
<main>
<span>¡Centro, por favor!</span>
</main>Ver resultadoabsolute-positioned position: absolute + calc() limit the width & height
<style>
main{
width: 100%;
min-height: 152px;
display: flex;
}
main > span {
position: absolute;
top: calc(50% - 16px);
left: calc(50% - 72px);
background: #b4a078;
color: white;
padding: .3em 1em .5em;
border-radius: 3px;
box-shadow: 0 0 .5em #b4a078;
}
</style>
<main>
<span>¡Centro, por favor!</span>
</main>Ver resultado



Comentarios