center text within a div over an image
by Donna Torr
HTML
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Plant Base</title>
<meta name="description" content="An interactive getting started guide for Brackets.">
<link rel="stylesheet" href="home.css">
</head>
<body>
<div class="card middle">
<div class="front">
<div class="front_card_icon">
<img src="https://auroraweb.ca/uploads/aurora/webpage/213/ananda-nye.jpg">
</div>
<p>THIS TEXT IS THE PROBLEM</p>
</div>
<div class="back">
<div class="back-content middle">
<p class="back-content_text">Indoor plants are one of the prevalent plant species!</p>
</div>
</div>
</div>
</body>
</html>
CSS
*{
margin: 0;
padding: 0;
text-decoration: none;
font-family: "cursive";
}
body {
background-image: url("https://crhnet.ca/wp-content/uploads/2024/08/Ideas-CRHNet-membership-cert-BH-1.png");
background-size: cover;
background-attachment: fixed;
}
.middle{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.card {
cursor: pointer;
width: 15vw;
height: 15vw;
}
.front, .back{
width: 100%;
height: 100%;
overflow: hidden;
backface-visibility: hidden;
position: absolute;
transition: transform .6s linear;
background-color: #2D3436;
line-height: 100%;
}
.front_card_icon{
position: relative;
bottom: 8%;
transform: scale(0.70);
z-index: 2;
}
.front p {
position:absolute;
top: 50%;
transform: translateY(-50%);
text-align: center;
color:white;
z-index:2;
}
.front img {
width:100%;
}
.back{
background: #f1f1f1;
transform: perspective(800px) rotateY(180deg);
}
.back-content{
color: #2c3e50;
text-align: center;
width:100%;
}
.card:hover > .front{
transform: perspective(800px) rotateY(-180deg);
}
.card:hover > .back{
transform: perspective(800px) rotateY(0deg);
}