Can't apply :not() to include div containers - html

I am trying to fade in everything on the screen except an image. I want the image to transform: scales(); bigger and than back down to original size.I have two container boxes that have some text and a form that I want to all fade in after the image.
I can get the image to animate and then everything else fade in but the div containers themselves do not animate. So there will be two empty boxes on the screen, the image animates and then the contents of the div fade in.
Here is my code:
.fadeIn :not(#ipad) {
-webkit-animation: fadeIn 3s ease;
-moz-animation: fadeIn 3s ease;
-ms-animation: fadeIn 3s ease;
-o-animation: fadeIn 3s ease;
animation: fadeIn 3s ease;
}
<div class="title fadeIn" id="title"><b>Curriculum and Instruction iPad Setup</b></div>
<div class="info-container fadeIn" id="info-container">
<img src="img/IPad_3.png" id="ipad">
<form action="login_complete.php" method="post" id="loginForm">
<div class="campus-container">
<input type="radio" name="campus" value="STE" /><span><b>Stephenville</b></span>
<input type="radio" name="campus" value="FTW" /><span><b>Fort Worth</b></span>
</div>
<input type="submit" value="Submit" onclick="loadingSpinner();" />
</form>
</div>
When I take off :not(#ipad) everything, including the image, fades in together. I want the image to not get the fade in animation.
I looked here but that didn't seem to work. I also found this but also no go.
EDITED:
Sorry about not enough css code:
the fade in
#keyframes fadeIn {
0% { opacity: 0; }
50% { opacity: 0; }
100% { opacity: 1; }
}
image animation
#keyframes zoomOut {
0% {
opacity: 0;
}
5% {
opacity: 1;
}
50% {
-webkit-transform: scale(5);
-moz-transform: scale(5);
-ms-transform: scale(5);
-o-transform: scale(5);
transform: scale(5);
}
100% { }
}

if you nest <img src="img/IPad_3.png" id="ipad">
inside <div class="info-container fadeIn" id="info-container">
you should not expect it to work.
that's all it takes. you have to rethink your document structure.
besides, css does not allow you to write look ahead expressions so you don't have any other choice but to change the document structure.
one way to fix it would be this:
change the info-container div to this:
<div class="info-container fadeIn iPad" id="info-container">
and change css from .fadeIn :not(#ipad) to .fadeIn:not(.iPad)
or alternatively just remove fadeIn from that div.
you could also change your css selector to this: .fadeIn {
and change your html to this:
<div class="title fadeIn" id="title"><b>Curriculum and Instruction iPad Setup</b></div>
<div class="info-container" id="info-container">
<img src="img/IPad_3.png" id="ipad">
<form action="login_complete.php" class="fadeIn" method="post" id="loginForm">
<div class="campus-container">
<input type="radio" name="campus" value="STE" /><span><b>Stephenville</b></span>
<input type="radio" name="campus" value="FTW" /><span><b>Fort Worth</b></span>
</div>
<input type="submit" value="Submit" onclick="loadingSpinner();" />
</form>
</div>

Related

In closing Angular dialog create a transition

I have created an animation when the dialog is opening but I want the same when the Angular dialog is closing.
This is my code for opening dialog with animation:
<div class="container">
<div class="body-container" [ngClass]="getBorderColor()">
</div>
<button mat-dialog-close>Cancel</button>
</div>
.body-container {
animation: animation-name .5s ease-out forwards;
}
#keyframes animation-name {
0% {
transform: translateX(100%); }
100% {
transform: translateX(0%);
}
}
And here is the stackblitz I have created.
https://stackblitz.com/edit/slow-dialog-f5nnnr?file=app%2Fdialog-overview-example-dialog.css

Transform not working properly on anchor

I am trying to animate a button making it translate a little bit to the right for a specific time, but somehow the transition never happens.
#keyframes moveXpath {
0% {
transform: translateX(-10px);
}
100% {
transform: translateX(100px);
}
}
.btn-animate {
animation-name: moveXpath;
animation-duration: 10s;
}
<body>
<div class="container">
<h1>button animation</h1>
<div class="buttons">
rotating button
</div>
</div>
</body>
lost some time and can't figure out what is wrong any help?
Anchor are inline elements transform does not work on these type of elements.
Add a different display (block or inline-block) to your anchor
.btn-animate {
animation-name: moveXpath;
animation-duration: 10s;
display: inline-block;
}
Source: w3.org

Trigger CSS animation with checkbox inside a fieldset

I try to trigger an animation only when a checkbox is checked.
I have the following code :
<div data-role="fieldcontain" >
<fieldset data-role="controlgroup" data-type="horizontal">
<input type="checkbox" class="mediaCheckbox" id="playCheck"/>
<label data-role="button" class="fa fa-play" id="play" for="playCheck"></label>
<input type="checkbox" class="mediaCheckbox" id="muteCheck"/>
<label data-role="button" class="fa fa-bell" id="mute" for="muteCheck"></label>
</fieldset>
</div>
<div id="stuffToAnimate"></div>
and the following CSS :
#stuffToAnimate {
position: relative;
-webkit-animation: ball 11s ease-in-out 0s infinite normal; /* Chrome, Safari, Opera */
-webkit-animation-play-state: paused;
}
#playCheck:checked **XXX**{
-webkit-animation-play-state: running;
}
#-webkit-keyframes ball {
0% {top:5%;}
40% {-webkit-transform: rotate(0deg);}
50% {-webkit-transform: rotate(180deg);top:80%;}
90% {-webkit-transform: rotate(180deg);}
100% {-webkit-transform: rotate(360deg);top:5%;}
}
My problem is: How to complete the **XXX** selector in order to trigger the animation. I could put the checkbox #playCheck in the same level as #stuffToAnimate, but it would mess up my presentation.
you could use jquery to give #stuffToAnimate a class
$('#playCheck:checkbox').click(function() {
if ($(this).is(":checked"))
{
$("#stuffToAnimate").addClass("animate");
}
else {
$("#stuffToAnimate").removeClass("animate");
}
});
your css will look like this
.animate{
-webkit-animation-play-state: running;
}

Adding class via js won't trigger css animation

I have a modified version of animate.css (added some delay, new timings and new positions), and it works really great when the classes are set by default (html document). But when I am adding the animate class dynamically via js, the animation is not executed!
Even more annoying, I did have it working at some point, but I can't get it to work again (using gumby framework and inview js to add a class when the element is on screen (adding .animated)) . The left box had the classes already in the html, and the right box have the .animate class added by js.
Example:
http://onepageframework.com/28_2_14/strange_anim.html
Any ideas why the right box is not animating?
Using the Gumby inview extension: http://gumbyframework.com/docs/extensions/#!/inview
Edit: added html:
<div class="six columns text-center fadeInLeftMedium delay_2 animated">
<!-- left box content here -->
</div>
<div class="six columns text-center fadeInLeftMedium delay_2 inview" data-classname="animated">
<!-- right box content here -->
</div>
css:
.animated {
-webkit-animation-duration: 1s;
-moz-animation-duration: 1s;
-o-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
-o-animation-fill-mode: both;
animation-fill-mode: both;
}
.delay_2 {
-webkit-animation-delay: 2s;
-moz-animation-delay: 2s;
-o-animation-delay: 2s;
animation-delay: 2s;
}
#-webkit-keyframes fadeInLeftMedium {
0% {
opacity: 0;
-webkit-transform: translateX(-400px);
}
100% {
opacity: 1;
-webkit-transform: translateX(0);
}
}
#-moz-keyframes fadeInLeftMedium {
0% {
opacity: 0;
-moz-transform: translateX(-400px);
}
100% {
opacity: 1;
-moz-transform: translateX(0);
}
}
#-o-keyframes fadeInLeftMedium {
0% {
opacity: 0;
-o-transform: translateX(-400px);
}
100% {
opacity: 1;
-o-transform: translateX(0);
}
}
#keyframes fadeInLeftMedium {
0% {
opacity: 0;
transform: translateX(-400px);
}
100% {
opacity: 1;
transform: translateX(0);
}
}
.fadeInLeftMedium {
-webkit-animation-name: fadeInLeftMedium;
-moz-animation-name: fadeInLeftMedium;
-o-animation-name: fadeInLeftMedium;
animation-name: fadeInLeftMedium;
}
The reason is the same why you can't re-trigger CSS based animations by just subsequently removing and adding a class. The reason is that browsers batch-up these modifications and optimize away the animation.
Reason and solutions are discussed here.
From the article, your options are (paraphrased):
Add a small delay before re-adding the class (not recommended)
Clone the element, remove it, and insert the clone
Have 2 identical animations (attached to different css rules) and switch between them
Trigger a reflow between removing and adding the class name:
element.classList.remove("run-animation");
// element.offsetWidth = element.offsetWidth; //doesn't work in strict mode
void element.offsetWidth; // reading the property requires a recalc
element.classList.add("run-animation");
Change (cycle) the element's CSS animation-play-state attribute to paused or running (does not restart animation)
By swaping the classes, it looks like it got it to work (aminated in the class, and fadeInLeftMedium as the data-classname):
<div class="six columns text-center fadeInLeftMedium delay_2 animated">
<!-- left box content here -->
</div>
<div class="six columns text-center animated delay_2 inview" data-classname="fadeInLeftMedium">
<!-- right box content here -->
</div>
I think you just need to add animated as a class rather than as data-classname="animated"...
So basically:
<div class="six columns text-center fadeInLeftMedium delay_2 inview" data-classname="animated">
<!-- right box content here -->
</div>
Should be:
<div class="six columns text-center fadeInLeftMedium delay_2 inview animated">
<!-- right box content here -->
</div>
Otherwise the animation lacks a specified animation duration and without the animation-duration property specified the animation won't work.

Hover Animation won't disappear when not hovering

I have a div I've animated on hover. However when I am not hovering the div won't disappear
This is what the entire thing looks like in action: http://jsfiddle.net/Vbxtc/
This is the html:
<nav>
<div id="controls">
<button id="playButton">Play</button>
<div id="defaultBar">
<div id="progressBar"></div>
</div>
<button id="vol" onclick="level()">Vol</button>
<button id="mute">Mute</button>
<button id="full" onclick="toggleFullScreen()">Full</button>
</div>
<div id="playlist" class="animated fadeInRight">
<div>cats</div>
<div>cats</div>
<div>cats</div>
</div>
</nav>
This is the CSS i've made:
#playlist{
position:absolute;
display:block;
border:1px solid red;
height: 82%;
width: 25%;
top: 20px;
right: 0px;
z-index: 2;
float:right;
padding: 0px;
margin: 0px;
color:white;
background-color:#999999;
opacity: 0;
}
#playlist:hover {
opacity: 1;
}
This is the animation im trying
.animated:hover {
-webkit-animation-fill-mode: both;
-moz-animation-fill-mode: both;
-ms-animation-fill-mode: both;
-o-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-duration: 1s;
-moz-animation-duration: 1s;
-ms-animation-duration: 1s;
-o-animation-duration: 1s;
animation-duration: 1s;
}
.fadeInRight {
-webkit-animation-name: fadeInRight;
-moz-animation-name: fadeInRight;
-o-animation-name: fadeInRight;
animation-name: fadeInRight;
}
#-webkit-keyframes fadeOutRight {
0% {
opacity: 1;
-webkit-transform: translateX(0);
}
100% {
opacity: 0;
-webkit-transform: translateX(20px);
}
}
#-webkit-keyframes fadeInRight {
0% {
opacity: 0;
-webkit-transform: translateX(20px);
}
100% {
opacity: 1;
-webkit-transform: translateX(0);
}
}
I noticed that when you time the mouse over exactly right (hover for about 1 second and move mouse up top), it DOES fade out nicely.
The other thing is, if you add the class fadeOutRight as follows:
<div id="playlist" class="animated fadeInRight fadeOutRight">
It fades out too quickly.
I know I didn't help much but the answer lies in the timing.
Also, if you had the fadeOutRight class on, for example, the sidebar, it works nicely!
<aside id="sidebar" class="fadeOutRight">
Perhaps, put the class of fadeOutRight on everything EXCEPT the fadeInRight div.
It's not a good idea to play with an element position in the hover state.
Even if you get to program it right (that is not easy), most of the time the user won't understand what's happening.
You can get flickering scenarios where, without the user moving the cursor, your div leaves the cursor position, canceling the hover, the div re-entering the cursor, the hover triggering , and so on.
I would recomend to trigger the hover on another div that covers the full area where the moving div will be.