1
In the example below we use, transform: translate(-50%,-50%);
to keep a text in the middle of the element. But it’s not a solution that works in all browsers. I would really like to do it, but with simple css or even with jquery.
.artigo-content {
background: #fff;
color: #666666;
border: 1px solid #F0F0F0;
padding: 0 30px;
height: 100%;
text-align: center;
position: relative;
height:300px;
}
.artigo-inner {
width: 90%;
margin: auto;
position: absolute;
top: 50%; left: 50%;
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
<div class="artigo-main">
<div class="artigo-content">
<div class="artigo-inner">
<h3><a href="#">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus at eleifend leo. Praesent eu ex ligula.</a></h3>
<p>Abril 26, 2018</p>
</div>
</div>
</div>
The simplest thing is
display:flex
– Isac
@Isac really the simplest form is with Flex indisputable. But browser support for Flex is even worse than Transform https:/caniuse.com/
– hugocsl
@hugocsl Although the support is not yet 100%. They all support from certain versions. The only ugly duckling is the same as usual, IE, but you’d expect it. With vendor prefixes goes further back in versions.
– Isac
@Isac Because it is the damn IE always it, but many companies only homologate for it, because thinking about what the author of the question spoke I made the comment.
– hugocsl
If you are using the
Bootstrap 4
, then you are already supporting only theIE 10
, and IE since version 9 supportstransformações 2d
– Tobias Mesquita