Is it possible to center a div on a webpage without specifying a fixed height, so that the height adjusts dynamically based on the content? I am willing to consider JS/jQuery solutions with fallback options but would prefer a pure CSS approach.
Currently, my code centers the div but requires a set 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;
}
This question stands out from previous discussions due to its timing and the advancements in CSS3 since the earlier topic was raised in 2011. New functionalities in CSS3 may provide an improved solution for this requirement.