I am trying to create a flip card which flips on mouse hover, like shown in this example - How To Create a Flip Card with CSS
So far I have succeeded in flipping the card, but the contents on the backside of the card are not visible.
Here is the code:
import dash
import dash_html_components as html
app = dash.Dash(__name__)
app.layout = html.Div([
html.Div([
html.Div([
html.Img(src='https://cdn.pixabay.com/photo/2020/07/01/12/58/icon-5359553_1280.png', style={'width':'300px', 'height':'200px'})
], className='flip-card-front')
], className='flip-card-inner'),
html.Div([
html.H1("John Doe")
], className='flip-card-back')
], className='flip-card')
if __name__ == '__main__':
app.run_server(debug=True)
Css file (same as in the example link):
/* The flip card container - set the width and height to whatever you want. We have added the border property to demonstrate that the flip itself goes out of the box on hover (remove perspective if you don't want the 3D effect */
.flip-card {
background-color: transparent;
width: 300px;
height: 200px;
perspective: 1000px; /* Remove this if you don't want the 3D effect */
}
/* This container is needed to position the front and back side */
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
/* Do an horizontal flip when you move the mouse over the flip box container */
.flip-card:hover .flip-card-inner {
transform: rotateY(180deg);
}
/* Position the front and back side */
.flip-card-front, .flip-card-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden; /* Safari */
backface-visibility: hidden;
}
/* Style the front side (fallback if image is missing) */
.flip-card-front {
background-color: skyblue;
color: black;
}
/* Style the back side */
.flip-card-back {
background-color: grey;
color: red;
transform: rotateY(180deg);
}
Any help would be appreciated, thank you