We would like to know how to hover to flip hexagon.
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.mm {<!--from ww w .ja v a 2s. c o m-->
margin-left: 100px;
margin-top: 100px;
}
.hexagon {
transition: all 0.5s ease-in-out;
width: 97px;
height: 70px;
background: red;
z-index: 2;
position: relative;
border-radius: 5px;
-moz-transform: scale(1, 0.8);
-ms-transform: scale(1, 0.8);
-webkit-transform: scale(1, 0.8);
-o-transform: scale(1, 0.8);
transform: scale(1, 0.8);
}
.hexagon:before, .hexagon:after {
transition: all 0.5s ease-in-out;
content: '';
display: block;
width: 70px;
height: 70px;
background: red;
z-index: -1;
left: 50%;
margin-left: -35px;
position: absolute;
border-radius: 5px;
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.hexagon:before {
top: -32px;
}
.hexagon:after {
bottom: -32px;
}
.hexagon>* {
transition: all 0.5s ease-in-out;
display: block;
margin: 0 auto;
-moz-transform: scale(1, 1.25);
-ms-transform: scale(1, 1.25);
-webkit-transform: scale(1, 1.25);
-o-transform: scale(1, 1.25);
transform: scale(1, 1.25);
}
.hexagon:hover {
-moz-transform: scale(1, -0.8);
-ms-transform: scale(1, -0.8);
-webkit-transform: scale(1, -0.8);
-o-transform: scale(1, -0.8);
transform: scale(1, -0.8);
background: red;
}
.hexagon:hover:before, .hexagon:hover:after {
background: red;
}
.hexagon:hover>* {
-moz-transform: scale(1, -1.25);
-ms-transform: scale(1, -1.25);
-webkit-transform: scale(1, -1.25);
-o-transform: scale(1, -1.25);
transform: scale(1, -1.25);
}
</style>
</head>
<body>
<div class="hexagon mm">
</div>
</body>
</html>
The code above is rendered as follows: