Reputation: 1
I think the error is in the logic. the animation works on when the CSS is set to change on hover, but when I try to add the click function then add the class, nothing happens. Here is the js fiddle: https://jsfiddle.net/lelales/6qmsgcjn/7/
here is an example of the animation working on hover: https://www.studiocaillouette.com/menu-test-css/
$("document").ready(function() {
$("#menu").click(function(){
$(".cirlce").addClass("circle-grow");
.circle,.content {
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 2s ease-in-out;
-ms-transition: all 2s ease-in-out;
transition: all 2s ease-in-out;
}
.circle {
background: rgba( 99, 99, 99, 0.8 );
box-shadow: 1px 2px 2px rgba( 0, 0, 0, 0.8 );
border-radius: 100%;
color: white;
text-align: center;
font-family: sans-serif;
padding: 20px;
overflow: hidden;
-webkit-transform: scale( 0.1 );
-moz-transform: scale( 0.1 );
-o-transform: scale( 0.1 );
-ms-transform: scale( 0.1 );
transform: scale( 0.1 );
width: 400px;
height: 400px;
line-height: 400px;
}
.circle-grow {
-webkit-transform: scale( 1 );
-moz-transform: scale( 1 );
-o-transform: scale( 1 );
-ms-transform: scale( 1 );
transform: scale( 1 );
vertical-align: middle;
}
.content {
opacity: .1;
}
.circle-grow .content {
opacity: 1;
}
<script
<div id="menu"><a href="#">menu</a></div>
<div class="circle">
<span class="content"><a href="index.html">home</a><br />
<a href="pricing.php">pricing</a><br />
<a href="gallery.php">gallery</a><br />
<a href="contact.php">contact</a><br />
</span>
</div>
Upvotes: 0
Views: 49
Reputation: 272
First of all, there was a typo error for "circle"
Please check the following fiddle
#circle {
background: rgba( 99, 99, 99, 0.8 );
box-shadow: 1px 2px 2px rgba( 0, 0, 0, 0.8 );
border-radius: 100%;
color: white;
text-align: center;
font-family: sans-serif;
padding: 20px;
overflow: hidden;
-webkit-transform: scale( 0.1 );
-moz-transform: scale( 01 );
-o-transform: scale( 0.1 );
-ms-transform: scale( 0.1 );
transform: scale( 0.1 );
width: 400px;
height: 400px;
line-height: 400px;
transition:ease all 1s
}
Upvotes: 0
Reputation: 11
typo error of the word 'cirlce' shoud change to 'circle':
$(".cirlce").addClass("circle-grow");
Upvotes: 1
Reputation: 16251
Add JQUERY script in head
tag:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
close functions with });
You have typo mistake use circle
and not $(".cirlce")
$("document").ready(function() {
$("#menu").click(function(){
$(".circle").addClass("circle-grow");
});
});
.circle,.content {
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 2s ease-in-out;
-ms-transition: all 2s ease-in-out;
transition: all 2s ease-in-out;
}
.circle {
background: rgba( 99, 99, 99, 0.8 );
box-shadow: 1px 2px 2px rgba( 0, 0, 0, 0.8 );
border-radius: 100%;
color: white;
text-align: center;
font-family: sans-serif;
padding: 20px;
overflow: hidden;
-webkit-transform: scale( 0.1 );
-moz-transform: scale( 0.1 );
-o-transform: scale( 0.1 );
-ms-transform: scale( 0.1 );
transform: scale( 0.1 );
width: 400px;
height: 400px;
line-height: 400px;
}
.circle-grow {
-webkit-transform: scale( 1 );
-moz-transform: scale( 1 );
-o-transform: scale( 1 );
-ms-transform: scale( 1 );
transform: scale( 1 );
vertical-align: middle;
}
.content {
opacity: .1;
}
.circle-grow .content {
opacity: 1;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="menu"><a href="#">menu</a></div>
<div class="circle">
<span class="content"><a href="index.html">home</a><br />
<a href="pricing.php">pricing</a><br />
<a href="gallery.php">gallery</a><br />
<a href="contact.php">contact</a><br />
</span>
</div>
Upvotes: 0