Using UI Bootstrap, I have a modal window as shown below. As per normal behavior, the rest of the site is shaded with a backdrop when the modal is opened, a shown below:
This modal itself can open another second modal. When this happens, the first modal is shaded in the same color as the rest of the site, as shown below:
However, my desired behavior when the second modal is open is for the rest of the site to have a darker shade for the backdrop and the first modal to have the normal shading. For example, this effect can be seen with two modals are opened in Twitter, as shown below:
This is the code that is used to display the first modal:
$rootScope.modalInstance = $uibModal.open({
templateUrl: 'WebApp/modalOne.html',
controller: 'modalOneController',
backdrop: 'static',
windowClass: 'app-modal-window'
});
And this displays the second modal:
$rootScope.modalInstance = $uibModal.open({
templateUrl: 'WebApp/modalTwo.html',
controller: 'modalTwoController',
backdrop: 'true',
windowClass: 'center-modal',
animation: false
});
And this is the relevant CSS:
.modal-backdrop,
.modal {
opacity: 0;
}
.app-modal-window.modal.in-add {
-webkit-animation: fadeIn 0.3s ease-out;
animation: fadeIn 0.3s ease-out;
}
.modal.in {
opacity: 1;
}
.modal-backdrop.in-add {
-webkit-animation: fadeIn 0.3s ease-out;
animation: fadeIn 0.3s ease-out;
}
.modal-backdrop.in {
animation: fadeInBackdrop 0.3s !important;
}
.modal-backdrop.in {
filter: alpha(opacity=50);
opacity: .5;
}
.modal.in {
opacity: 1;
}
.app-modal-window.modal.in-remove {
-webkit-animation: fadeOut 0.2s ease-out;
animation: fadeOut 0.2s ease-out;
opacity: 0;
}
.modal-backdrop.in-remove {
-webkit-animation: fadeOutBackdrop 0.2s ease-out;
animation: fadeOutBackdrop 0.2s ease-out;
opacity: 0;
}
.modal.fade .modal-dialog, .modal.in .modal-dialog {
-webkit-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0);
}
#-webkit-keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
#-webkit-keyframes fadeInBackdrop {
from {
opacity: 0;
}
to {
opacity: 0.5;
}
}
#keyframes fadeInBackdrop {
from {
opacity: 0;
}
to {
opacity: 0.5;
}
}
#-webkit-keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
#keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
#-webkit-keyframes fadeOutBackdrop {
from {
opacity: 0.5;
}
to {
opacity: 0;
}
}
#keyframes fadeOutBackdrop {
from {
opacity: 0.5;
}
to {
opacity: 0;
}
}
.center-modal.modal {
text-align: center;
}
#media screen and (min-width: 768px) {
.center-modal.modal:before {
display: inline-block;
vertical-align: middle;
content: " ";
height: 100%;
}
}
.center-modal .modal-dialog {
display: inline-block;
text-align: left;
vertical-align: middle;
}
Regarding the CSS, please note that I had to do some experimenting to change UI Bootstap's default animation to my requirements. These requirements were to fade in/out both the backdrop and modal simultaneously with no vertical movement animation of the modal. Therefore, the CSS might be a little messy.
Any help/advice is appreciated.
Related
I have a React application that holds just a simple static website. I have some CSS animations using keyframes which work as expected when testing it in the node development server using npm start but when I push the project to my live site using Firebase hosting, all animations stop working as expected. The fade-in-* classes no longer slowly fade in, the text just 'pops' into place with no gradual opacity change. Can anyone see why this might be?
I have added -moz- and -webkit- keyframes also. This seems to be the case on all browsers. Tested in Edge, Chromew and Firefox, all give the same result.
main.css
.font-big {
font-size: 1.2rem!important;
}
.font-small {
font-size: 0.8rem;
}
.text-black {
color: black;
}
.hidden {
display: none;
}
.footer {
width: 100%;
height: 60px;
line-height: 60px;
background-color: #f5f5f5;
}
.welcome-fade-in {
-moz-animation: fade-in-welcome 1s ease-in;
-webkit-animation: fade-in-welcome 1s ease-in;
animation: fade-in-welcome 1s ease-in;
}
.welcome-name-in {
-moz-animation: fade-in-welcome-name 2s ease-in;
-webkit-animation: fade-in-welcome-name 2s ease-in;
animation: fade-in-welcome-name 2s ease-in;
}
.welcome-text-in {
-moz-animation: fade-in-welcome-text 3s ease-in;
-webkit-animation: fade-in-welcome-text 3s ease-in;
animation: fade-in-welcome-text 3s ease-in;
}
.welcome-text-explore {
-moz-animation: fade-in-explore-text 4s ease-in;
-webkit-animation: fade-in-explore-text 4s ease-in;;
animation: fade-in-explore-text 4s ease-in;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
background-image: url("./bg.gif");
}
#keyframes fade-in-welcome {
0% {
opacity: 0;
}
100% {
opacity: 100%;
}
}
#keyframes fade-in-welcome-name {
0% {
opacity: 0;
}
50% {
opacity: 0;
}
100% {
opacity: 100%;
}
}
#keyframes fade-in-welcome-text {
0% {
opacity: 0;
}
70% {
opacity: 0;
}
100% {
opacity: 100%;
}
}
#keyframes fade-in-explore-text {
0% {
opacity: 0;
}
75% {
opacity: 0;
}
100% {
opacity: 100%;
}
}
#-moz-keyframes fade-in-welcome {
0% {
-moz-opacity: 0;
}
100% {
-moz-opacity: 100%;
}
}
#-moz-keyframes fade-in-welcome-name {
0% {
-moz-opacity: 0;
}
50% {
-moz-opacity: 0;
}
100% {
-moz-opacity: 100%;
}
}
#-moz-keyframes fade-in-welcome-text {
0% {
-moz-opacity: 0;
}
70% {
-moz-opacity: 0;
}
100% {
-moz-opacity: 100%;
}
}
#-moz-keyframes fade-in-explore-text {
0% {
-moz-opacity: 0;
}
75% {
-moz-opacity: 0;
}
100% {
-moz-opacity: 100%;
}
}
#-webkit-keyframes fade-in-welcome {
0% {
opacity: 0;
}
100% {
opacity: 100%;
}
}
#-webkit-keyframes fade-in-welcome-name {
0% {
opacity: 0;
}
50% {
opacity: 0;
}
100% {
opacity: 100%;
}
}
#-webkit-keyframes fade-in-welcome-text {
0% {
opacity: 0;
}
70% {
opacity: 0;
}
100% {
opacity: 100%;
}
}
#-webkit-keyframes fade-in-explore-text {
0% {
opacity: 0;
}
75% {
opacity: 0;
}
100% {
opacity: 100%;
}
}
Landing.js
import React, {Component} from 'react';
import {Link} from "react-router-dom";
import * as ROUTES from "../constants/routes";
class Landing extends Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="container d-flex justify-content-center h-100">
<div className="row align-self-center">
<div className="col-12 text-center flex-wrap">
<h1 className="text-uppercase welcome-fade-in">Welcome to my website</h1>
<h2 className="welcome-name-in">My name is Adam Foot</h2>
<h3 className="welcome-text-in">A Front-End Developer from Stroud</h3>
<Link to={ROUTES.HOME} className="text-decoration-none text-black align-self-end"><h4 className="welcome-text-explore">Explore >>></h4></Link>
</div>
</div>
</div>
);
}
}
export default Landing;
I have the following SVG animation that works perfectly fine in Chrome, Safari, Firefox but the line drawing doesn't display in IE.
I tried just the line drawing without the fade or moving away from the css shorthands but no change.
Any help or suggestion would be appreciated.
http://jsfiddle.net/zpL4okys/
.path {
stroke:#fff;
fill:transparent;
stroke-width:1;
opacity: 0;
-webkit-animation: dash 1.5s linear forwards, fadeout 1.9s linear;
animation: dash 1.5s linear forwards, fadeout 1.9s linear;
}
.drawing {
position: relative;
}
.illustration, .line-drawing {
position: absolute;
top:20%;
left:0;
right: 0;
margin: auto;
}
.illustration {
opacity: 1;
animation: fadein 2s ease-in;
}
#keyframes dash {
to {
stroke-dashoffset: 0;
}
}
#keyframes fadeout {
0% {
opacity:1;
}
99% {
opacity: 1;
}
100% {
opacity: 0;
}
}
#keyframes fadein {
0% {
opacity: 0;
}
90% {
opacity: 0;
}
100% {
opacity: 1;
}
}
I want to animate opacity from 0 to 1 so it show fade out to white animation, First I've used before pseudo element but it didn't work so I replaced it with div but got the same results here is the code:
body {
background: black;
}
.tv {
height: 100vh;
position: relative;
}
.white {
height: 100%;
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
background: white;
z-index: 1;
opacity: 0;
/* infinite while debugging */
animation: opacity 5s ease-out infinite;
animation-fill-mode: forwards;
}
#keyframes opacity {
0%: { opacity: 0 }
100%: { opacity: 1; }
}
<div class="tv">
<div class="white"></div>
</div>
My first keyframe was like this:
#keyframes opacity {
to: { opacity: 1; }
}
What's wrong with this animation?
Remove colons after 0% and 100% and you will get the animation. Try like this:
#keyframes opacity {
0% { opacity: 0 }
100% { opacity: 1; }
}
I am trying to show or hide the title of sidepanel while collapsing it to width:50%
I am using display: block to display:none;
Somehow I am not able to use the animation on it
Here is the code I am using
.fade-in {
animation: fade-in 0.5s ease-in-out both;
}
.fade-out {
animation: fade-out 0.6s ease-in-out both;
}
#keyframes fade-in {
0% {
opacity: 1;
display: block;
}
100% {
opacity: 0;
display: none;
}
}
#keyframes fade-out {
0% {
opacity: 0;
display: none;
}
100% {
opacity: 1;
display: block;
}
}
Any idea why display is not working
.fade-in {
animation: fade-in 0.5s ease-in-out both;
background:black;
height:200px;
width:200px;
margin-bottom:10px;
}
.fade-out {
animation: fade-out 0.6s ease-in-out both;
background:red;
height:200px;
width:200px;
}
#keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#keyframes fade-out {
0% {
opacity: 1;
display: none;
}
100% {
opacity: 0;
}
}
<div class="fade-in"></div>
<div class="fade-out"></div>
I have three divs I fade in based on a waypoint on the page. I am trying to stagger these divs. The issue I'm having is because I am fading them in from opacity: 0, once the 'animated' class is added, all the divs display (and then the delayed divs will play their animation from opacity: 1). This is probably a stupid question but I can't think of a way to delay the opacity on the 2nd and 3rd divs without having to give them individual animated classes. Any help would be much appreciated!
.project {
opacity: 0;
}
.project.animated {
opacity: 1;
animation-name: fadeInDown;
animation-duration: 1s;
&:nth-child(2) {
animation-delay: .3s;
}
&:nth-child(3) {
animation-delay: .6s;
}
}
#keyframes fadeInDown {
from {
opacity: 0;
transform: translate3d(0, -40%, 0);
}
to {
opacity: 1;
transform: none;
}
}
Compiled CSS:
.project {
opacity: 0;
}
.project.animated {
opacity: 1;
animation-name: fadeInDown;
animation-duration: 1s;
}
.project.animated:nth-child(2) {
animation-delay: .3s;
}
.project.animated:nth-child(3) {
animation-delay: .6s;
}
#keyframes fadeInDown {
from {
opacity: 0;
transform: translate3d(0, -40%, 0);
}
to {
opacity: 1;
transform: none;
}
}
Option 1:
Remove the opacity: 1 from the .animated class and add animation-fill-mode: forwards. This setting means that the animated element will maintain the state as at its last keyframe (which has the opacity: 1) and so there is no need for the extra property setting.
window.onload = function() {
setTimeout(function() {
var els = document.querySelectorAll('.project');
for (var i = 0; i < els.length; i++) {
els[i].classList.add('animated');
}
}, 100);
}
.project {
opacity: 0;
}
.project.animated {
/*opacity: 1;*/
animation-name: fadeInDown;
animation-duration: 1s;
animation-fill-mode: forwards;
}
.project.animated:nth-child(2) {
animation-delay: .3s;
}
.project.animated:nth-child(3) {
animation-delay: .6s;
}
#keyframes fadeInDown {
from {
opacity: 0;
transform: translate3d(0, -40%, 0);
}
to {
opacity: 1;
transform: none;
}
}
/* just for demo */
.project {
height: 100px;
width: 100px;
background: red;
<div class='project'>First</div>
<div class='project'>Second</div>
<div class='project'>Third</div>
Option 2:
If for whatever reasons you don't want to remove the opacity: 1 from the .animated class then set the animation-fill-mode: backwards to the element. This would make the animated element hold the state mentioned in its first keyframe (opacity: 0) during the animation-delay period and hence the element would not show up immediately.
window.onload = function() {
setTimeout(function() {
var els = document.querySelectorAll('.project');
for (var i = 0; i < els.length; i++) {
els[i].classList.add('animated');
}
}, 100);
}
.project {
opacity: 0;
}
.project.animated {
opacity: 1;
animation-name: fadeInDown;
animation-duration: 1s;
animation-fill-mode: backwards;
}
.project.animated:nth-child(2) {
animation-delay: .3s;
}
.project.animated:nth-child(3) {
animation-delay: .6s;
}
#keyframes fadeInDown {
from {
opacity: 0;
transform: translate3d(0, -40%, 0);
}
to {
opacity: 1;
transform: none;
}
}
/* just for demo */
.project {
height: 100px;
width: 100px;
background: red;
<div class='project'>First</div>
<div class='project'>Second</div>
<div class='project'>Third</div>
.project.animated {
opacity: 1; <- REMOVE THIS
animation-name: fadeInDown;
animation-duration: 1s;
[...]
You don't need to specify opacity: 1; in the class, the #keyframes animation will take care of animating each <div> to full opacity.