Forum Moderators: not2easy
I am trying to have the image and then the text overlaying the image
.container {
display: table;
width: 300px;
height: 300px;
/* position: relative; */
background: url("image.jpg");
border: 1px solid blue;
}
.content {
display: table-cell;
text-align: center;
vertical-align: middle;
/* position: absolute;
width: 100%;
height: 100%; */
}
<div class="container">
<div class="content">
Unknown stuff to be centered.
</div>
<!-- <img src="image.jpg" height="300px" width="300px" alt=""> -->
</div>
It needs to be adaptable.
An ‘auto’ value for one dimension is resolved by using the image's intrinsic ratio and the size of the other dimension, or failing that, using the image's intrinsic size, or failing that, treating it as 100%.
If both values are ‘auto’ then the intrinsic width and/or height of the image should be used, if any, the missing dimension (if any) behaving as ‘auto’ as described above.