JSFiddle - React, Tailwind, and code Playground
by Suh Valentine
HTML
<div class="cont-img">
<div class="image">
</div>
<div class="desc">
<div class="centered-items">
<div class="item1">
asdasd
</div>
<div class="item2">
asdasd
</div>
</div>
</div>
</div>
CSS
.cont-img {
width: 400px;
height: 400px;
position: relative;
}
.image {
width: 400px;
height: 400px;
background: black;
}
.desc {
position: absolute;
top: 0px;
height: 100%;
width: 100%;
color: gold;
display: table;
/*----ADDED1: I added this to your current code
This uses display: flex; If you still interested in using it
remove the ADDED2 css--*/
/*display: -webkit-flex;
flex-direction: column;
-webkit-flex-direction: column;
justify-content: center;
-webkit-justify-content: center;
align-items: center;
-webkit-align-items: center;*/
}
/*---ADDED2: This is what I added---*/
.centered-items {
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.item1,
.item2 {}