I want to display a div in the centre of my page without having to define a set height for the element so that the height fits the content of the page dynamically. Is this possible? I am open to using JS/jQuery solutions as long as they have graceful fallbacks but I would prefer pure CSS solution.
Here is my current code, it will centre the div, but I have to include a height.
HTML
<div class="card">Lorem ipsum dolor sit amet, minim molestie argumentum est at,
pri legere torquatos instructior ex. Vis id odio atomorum oportere, quem modo fabellas sit
at, dicat semper est ne. Apeirian detraxit pri eu. No solum accusam has. Ius ne harum mundi
clita, eu pro tation audiam.
</div>
CSS
.card {
background-color: #1d1d1d; /* IE fallback */
background-color: rgba(29, 29, 29, 0.95);
color: #fff;
display: inline-block;
margin: auto;
position: absolute;
bottom: 0;
top: 0;
left: 0;
right: 0;
padding: 30px 35px;
outline: 2px solid #3B3A37;
outline-offset: -9px;
width: 320px;
height: 350px;
/*margin: 0 auto;*/
}
This question is different from previous topics because of the time it has been asked, the similar question that it has been compared to is dated from 2011 in which a lot has changed and new functions have been added to CSS3 that could fulfil the requirement better.