JSFiddle - React, Tailwind, and code Playground
by alexflav23
HTML
<div class="containMe">
<div class="circle contracted" style="background-color:#15c3a8">
<p>TEST 1</p>
</div>
</div>
<div class="containMe">
<div class="circle contracted" style="background-color:#15c3a8">
<p>TEST 2</p>
</div>
</div>
CSS
.containMe {
position:absolute;
top:5px;
left: 0px;
z-index:5
}
.containMe {
width: 147px;
height: 147px;
position: relative;
margin: 40px;
text-align: center;
line-height: 147px;
}
.contracted {
width: 147px;
height: 147px;
margin: 0;
display: block;
position: relative;
overflow: hidden;
-webkit-border-radius: 75px;
-moz-border-radius: 75px;
border-radius: 75px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
-ms-transition: all 0.3s;
transition: all 0.3s;
}
.expanded {
width: 285px;
height: 285px;
line-height: 285px;
-webkit-border-radius: 150px;
-moz-border-radius: 150px;
border-radius: 150px;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
-ms-transition: all 0.3s;
transition: all 0.3s;
}
JavaScript
var events = "mouseover mouseout";
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
events =" touchstart";
};
$('.circle').on(events,function(){
if ($(this).hasClass("expanded")) {
// contract the circle
$(this).addClass("contracted").removeClass("expanded");
} else {
// expand the circle
$(this).addClass("expanded").removeClass("contracted");
};
});