html - Run a chain animation on different selectors by clicking once on a button -
I'm trying to run 2 CSS3 animations by clicking on a button. The first animation button rotates and disappears, and the second animation changes the second button, and it looks (the opacity has been changed from 0.5 to 1) and changes its height.
The problem is that only the first animation runs. The first animation name is
q1leave
and the other is the animation name
q2show P> To run the first animation I use the
# btnq1: target on the CSS and I to run the second animation I
# btnq1: target # btnq2a
See my code below:
HTML code
& lt; Div id = "q1" & gt; & Lt; Div class = "q1once" & gt; & Lt; A href = "# btnq1" & gt; & Gt; Button type = "button" name = "" value = "" id = "btn q1" & gt; Click to disappear, and then a different element & lt; / Button & gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Button type = "button" name = "" value = "" id = "btnq2a" & gt; & Gt; & Gt; Button & gt;
CSS code
# q1 {height: 100%; } .q1once {width: 20%; Height: 15%; Status: Completed; Left: -50%; Animation Name: Q1; Animation-Delay: 3s; Animation- Count of Travel: 1; Animation-period: 1.5s; Animation Fill-Mode: Forward; } #BTN1: Goal {Animation-Name: q1leave; Animation- Count of Travel: 1; Animation-period: 4s; Animation Fill-Mode: Forward; } # BTNA1: Target # BTNK2A Animation-Name: Q2Show; Animation- Count of Travel: 1; Animation-Delay: 4s; Animation-period: 4s; Animation Fill-Mode: Forward; } @ Keyframes Q1 {50% {Conversion: Translation (440%) Scale (3); } 100% {conversion: translation (450%) scale (1.5, 2); }} @ Keyframe q1leave {0% {transform: rotate (0deg); Opacity: 1; } 100% {Opacity: 0; As a result rotate (360deg); }} @ Keyframe q2show {100% {Opacity: 1; Height: 200px; }} # Btnk2a {opacity: 0.5; }
You can also do with me, I want to solve it using only CSS3, but I will accept other solutions using JS, jquery or other. What am i doing wrong
Javascript will be the easiest way to add a square to the second goal whenever the first click is clicked. is.
var btn1 = document.getElementById ('btnq1'); Var btn2 = document.getElementById ('btnq2a'); Btn1.addEventListener ('Click, MakeActive); Function MakeActive () {var className = '' + btn2.className + ''; // SO SO Question # 14615712 if (~ className.indexOf ('active')) {btn2.className = className.replace ('active', ''); } And {btn2.className + = 'active'; }}
or jQuery if you want:
$ ('# btnq1'). ('Click', function () {$ ('# btnq2a'). ToggleClass ('active');});
Then, adjust your CSS selector a bit.
# btnq2a.active {animation-name: q2show; Animation- Count of Travel: 1; Animation-Delay: 4s; Animation-period: 4s; Animation Fill-Mode: Forward; }
This is an update
Comments
Post a Comment