CSS works on Desktop, Strange on Mobile - javascript

I've got this great script. It flips the page and reveals new items using a JS code on the backside of this text. But for some reason, on mobile, things go wrong. The h1 and h2 elements disappear...
The issue lies in this css, when I remove the #keyframes it goes away (but then I lose my background):
.background{position:absolute;top:0px;right:0px;bottom:0px;left:0px}
.blue-purple{background-color:#2474c6;background-image:-webkit-linear-gradient(left, #2474c6, #165730);background-image:linear-gradient(to right,#2474c6, #165730);-webkit-animation:fadeInOut 13s ease;-moz-animation:fadeInOut 13s ease;animation:fadeInOut 13s ease;-webkit-animation-fill-mode:forwards;-moz-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;animation-iteration-count:infinite}
.green-blue{background-color:#165730;background-image:-webkit-linear-gradient(left, #165730, #185a9d);background-image:linear-gradient(to right,#165730, #185a9d);-webkit-animation:fadeOutIn 13s ease;-moz-animation:fadeOutIn 13s ease;animation:fadeOutIn 13s ease;-webkit-animation-fill-mode:forwards;-moz-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;animation-iteration-count:infinite}
#-webkit-keyframes "fadeInOut"{0%{opacity:0;}50%{opacity:1;}100%{opacity:0;}}
#-moz-keyframes "fadeInOut"{0%{opacity:0;}50%{opacity:1;}100%{opacity:0;}}
#keyframes "fadeInOut"{0%{opacity:0;}50%{opacity:1;}100%{opacity:0;}}
#-webkit-keyframes "fadeOutIn"{0%{opacity:1;}50%{opacity:0;}100%{opacity:1;}}#-moz-keyframes "fadeOutIn"{0%{opacity:1;}50%{opacity:0;}100%{opacity:1;}}
#keyframes "fadeOutIn"{0%{opacity:1;}50%{opacity:0;}100%{opacity:1;}}
#-webkit-keyframes "fadeIn"{from{opacity:0;}to{opacity:1;}}
#-moz-keyframes "fadeIn"{from{opacity:0;}to{opacity:1;}}
#keyframes "fadeIn"{from{opacity:0;}to{opacity:1;}}#-webkit-keyframes "fadeOut"{from{opacity:1;}to{opacity:0;}}
#-moz-keyframes "fadeOut"{from{opacity:1;}to{opacity:0;}}
#keyframes "fadeOut"{from{opacity:1;}to{opacity:0;}}
and some of the HTML:
<body>
<!----><div class="background blue-purple"></div>
<div class="background green-blue"></div>
<div class="container">
<div class="front">
<div class="inner">
<h1>text here</h1>
</div>
<span>sub text</span>
</div>
<div class="back">
<h2>Text</h2>
<p>Further Text</p>
</div>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="assets/js/index.js"></script>
</body>

Related

JQuery FadeIn & CSS slide in is choppy

JSFiddle
I'm not happy with the current result of the code in the fiddle, I'd like it to be less choppy and just fade in while also sliding in from the bottom but my JQuery skills are not the greatest. Is using CSS as the slide in the best choice? Wasn't able to find any examples of sliding in using JQuery.
Any help much appreciated.
Here's the same code.
<!doctype html>
<html lang="en">
<style>
#keyframes slideInFromBottom {
0% {
transform: translateY(100%);
}
100% {
transform: translateY(0);
}
}
.v1 {
animation: 1s ease-out 0s 1 slideInFromBottom;
}
.v2 {
animation: 1s ease-out 0.2s 1 slideInFromBottom;
}
.v3 {
animation: 1s ease-out 0.4s 1 slideInFromBottom;
}
</style>
<head>
<meta charset="utf-8">
<title>Vista Report</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
</head>
<body>
<div class="row">
<div class="col s12 m4">
<div class="card v1" id="v1">
<div class="card-image">
<img id="preload_v1" src="https://images.unsplash.com/photo-1469461084727-4bfb496cf55a?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=e7e60237ffbd8c98a087f464f44931c1&auto=format&fit=crop&w=1955&q=80" style="display:none;">
<span class="card-title">Card Title</span>
</div>
<div class="card-content">
<p>I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively.</p>
</div>
</div>
</div>
<div class="col s12 m4">
<div class="card v2" id="v2">
<div class="card-image">
<img id="preload_v2" src="https://images.unsplash.com/photo-1469461084727-4bfb496cf55a?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=e7e60237ffbd8c98a087f464f44931c1&auto=format&fit=crop&w=1955&q=80" style="display:none;">
<span class="card-title">Card Title</span>
</div>
<div class="card-content">
<p>I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively.</p>
</div>
</div>
</div>
<div class="col s12 m4">
<div class="card v3" id="v3">
<div class="card-image">
<img id="preload_v3" src="https://images.unsplash.com/photo-1469461084727-4bfb496cf55a?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=e7e60237ffbd8c98a087f464f44931c1&auto=format&fit=crop&w=1955&q=80" style="display:none;">
<span class="card-title">Card Title</span>
</div>
<div class="card-content">
<p>I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively.</p>
</div>
</div>
</div>
</div>
</body>
<script>
$("#v1").ready(function(){
$("#preload_v1").fadeIn(2000);
});
$("#v2").ready(function(){
$("#preload_v2").fadeIn(2000);
});
$("#v3").ready(function(){
$("#preload_v3").fadeIn(2000);
});
</script>
</html>
I removed the jQuery scripts and made it work with css alone.
replaced style="display:none" on img tag with following css
.card{
opacity:0;
}
For fadeIn effect changed opacity from 0 to 1
#keyframes slideInFromBottom {
0% {
transform: translateY(100%);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}
To keep the animation in final state added forwards to animation and also updated animation-duration and animation-delay
.v1 {
animation: 1s ease-out 0s 1 slideInFromBottom forwards;
}
.v2 {
animation: 1.2s ease-out 0.2s 1 slideInFromBottom forwards;
}
.v3 {
animation: 1.4s ease-in 0.4s 1 slideInFromBottom forwards;
}
Demo

How to change Bootstrap tabs fade OUT speed?

I am trying to change the speed of a fade effect in Bootstrap. I found this answer using css:
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
.fade {
opacity: 0;
-webkit-transition: opacity 1.5s linear;
-moz-transition: opacity 1.5s linear;
-ms-transition: opacity 1.5s linear;
-o-transition: opacity 1.5s linear;
transition: opacity 1.5s linear;
}
<div class="btn-group" role="group">
<button class="btn active" data-toggle="tab" href="#one">One</button>
<button class="btn" data-toggle="tab" href="#two">Two</button>
<button class="btn" data-toggle="tab" href="#three">Three</button>
</div>
<div class="tab-content">
<div id="one" class="tab-pane fade in active">This is the One</div>
<div id="two" class="tab-pane fade">This is the Two</div>
<div id="three" class="tab-pane fade">This is the Three</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
...but this only affects the fade-in time. The fade-out stays the same. Any suggestions?
There is no fade-out time, the class that makes the element visible just gets removed.
To make it fade-out, you have to make sure the item doesn't get removed from the dom (HTML document), but rather make it invisible so it can fade.
Here is an example, adjust to your wishes:
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
.tab-content {
position:relative;
}
.tab-content>.tab-pane {
/* in order to make sure the elements are nicely in position
use position:absolute; */
position:absolute;
top:0;
}
.fade {
opacity: 0;
-webkit-transition: opacity 1.5s linear;
-moz-transition: opacity 1.5s linear;
-ms-transition: opacity 1.5s linear;
-o-transition: opacity 1.5s linear;
transition: opacity 1.5s linear;
}
.tab-content>.tab-pane:not(.in) {
/* display:none; is the default behaviour, make that display:block; */
display:block;
/* make the opacity 0, that is what the transition responds to! */
opacity:0;
}
<div class="btn-group" role="group">
<button class="btn active" data-toggle="tab" href="#one">One</button>
<button class="btn" data-toggle="tab" href="#two">Two</button>
<button class="btn" data-toggle="tab" href="#three">Three</button>
</div>
<div class="tab-content">
<div id="one" class="tab-pane fade in active">This is the One</div>
<div id="two" class="tab-pane fade">This is the Two</div>
<div id="three" class="tab-pane fade">This is the Three</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
The issue is that when an item is not active, it's display property is set to display:none, and therefore is being hidden before any animation can be applied. If you position everything using absolute position to overlap, then you can leave the display as display:block and just change the opacity:
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
.fade {
opacity: 0;
-webkit-transition: opacity 1.5s linear;
-moz-transition: opacity 1.5s linear;
-ms-transition: opacity 1.5s linear;
-o-transition: opacity 1.5s linear;
transition: opacity 1.5s linear;
}
.tab-content {
position:relative;
}
.tab-content>.tab-pane {
top: 0;
position:absolute;
display:block;
}
.tab-content>.tab-pane:not(.active) {
opacity: 0;
}
<div class="btn-group" role="group">
<button class="btn active" data-toggle="tab" href="#one">One</button>
<button class="btn" data-toggle="tab" href="#two">Two</button>
<button class="btn" data-toggle="tab" href="#three">Three</button>
</div>
<div class="tab-content">
<div id="one" class="tab-pane fade in active">This is the One</div>
<div id="two" class="tab-pane fade">This is the Two</div>
<div id="three" class="tab-pane fade">This is the Three</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
If you simply want to avoid having the fade affect, or need the tabs to appear more quickly remove the fade class.
// Original
<div class="tab-content">
<div id="one" class="tab-pane fade in active">This is the One</div>
<div id="two" class="tab-pane fade">This is the Two</div>
<div id="three" class="tab-pane fade">This is the Three</div>
</div>
// Updated
<div class="tab-content">
<div id="one" class="tab-pane in active">This is the One</div>
<div id="two" class="tab-pane fade">This is the Two</div>
<div id="three" class="tab-pane fade">This is the Three</div>
</div>
The fade class is only applied to the first pane, then when the button is clicked then Jquery removes the active class and fade class and applies it to the corresponding pane.

How to animate a div over other divs if float left is enabled?

Basically, I have a parent div with a width of 100%, and 3 sub-divs with a width of 33.333333% each. All 3 divs are floated left so they align in one row.
I want to animate one of the 33.333333% div to 100% but what I want it to do is to go over the other 2 divs without it being pushed to the next row?
<div id="fullwidth">
<div id="history" class="thirdwidth">
<h1>Our History</h1>
</div>
<div id="now" class="thirdwidth">
<h1>Now</h1>
</div>
<div id="whatwedo" class="thirdwidth">
<h1>What We Do</h1>
</div>
</div>
How do I do this?
See example here:
https://jsfiddle.net/y9qcd2wc/2/
$(".thirdwidth").on("click", function(){
$(this).toggleClass("active");
});
html, body{margin:0; height:100%;}
.thirdwidth {
position:absolute;
z-index:0;
top:0;
width: 33.333%;
height: 100%;
transition: 0.4s; -webkit-transition: 0.4s;
}
.thirdwidth.push0{left:0%;}
.thirdwidth.push1{left:33.333%;}
.thirdwidth.push2{left:66.333%;}
#history {background:red;}
#now {background:green;}
#whatwedo{background:blue;}
.thirdwidth.active{z-index:1; left:0; width:100%;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="fullwidth">
<div id="history" class="thirdwidth push0">
<h1>Our History</h1>
click to maximize, and click again to minimize
</div>
<div id="now" class="thirdwidth push1">
<h1>Now</h1>
</div>
<div id="whatwedo" class="thirdwidth push2">
<h1>What We Do</h1>
</div>
</div>

Angular .ng-hide-remove animation doesn't work

I have this CSS:
#platinumHeader.ng-hide-remove {
-webkit-animation: fadeInDown 0.5s!important;
-moz-animation: fadeInDown 0.5s!important;
-o-animation: fadeInDown 0.5s!important;
animation: fadeInDown 0.5s!important;
}
And this HMTL:
<header class="navbar-fixed-top header-floating" data-ng-show="isHeader" id="platinumHeader">
<div class="container">
...
</div>
</header>
But when my header is shown (i.e. isHeader is set to true) it just appears without animation.
But if I write CSS like this (without #platinumHeader selector):
.ng-hide-remove {
-webkit-animation: fadeInDown 0.5s!important;
-moz-animation: fadeInDown 0.5s!important;
-o-animation: fadeInDown 0.5s!important;
animation: fadeInDown 0.5s!important;
}
It works fine. What am I doing wrong ?
Try with ngClass directive
<header class="navbar-fixed-top header-floating" ng-class="{'ng-hide-remove' : isHeader}" data-ng-show="isHeader" id="platinumHeader">
<div class="container">
</div>
</header>

Change Slit Slider Revised effect to fadein fadeout

I am coding a website which needs the full-screen fadein fadeout slider with content and next previous navigation . So I found this.
But the main problem is that I need this effect to fadein fadeout.
You can use bootstrap-carousel
http://getbootstrap.com/javascript/#carousel
For auto-gen help
http://www.bootply.com/64693
Here I'm giving one work-around for you with this fiddle http://jsfiddle.net/fj75wqwc/
The same is below:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.css" />
<style>
.carousel.carousel-fade .item {
-webkit-transition: opacity 0.5s ease-in-out;
-moz-transition: opacity 0.5s ease-in-out;
-ms-transition: opacity 0.5s ease-in-out;
-o-transition: opacity 0.5s ease-in-out;
transition: opacity 0.5s ease-in-out;
opacity: 0;
}
.carousel.carousel-fade .active.item {
opacity: 1;
}
.carousel.carousel-fade .active.left,
.carousel.carousel-fade .active.right {
left: 0;
z-index: 2;
opacity: 0;
filter: alpha(opacity=0);
}
.carousel.carousel-fade .next,
.carousel.carousel-fade .prev {
left: 0;
z-index: 1;
}
.carousel.carousel-fade .carousel-control {
z-index: 3;
}
</style>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="page-header text-center">
<h1>Bootstrap Carousel with fade effect</h1>
</div>
<div class="span6 offset3">
<div id="carousel_fade" class="carousel slide carousel-fade">
<div class="carousel-inner">
<div class="item active">
<!-- you can add any content here-->
<img src="http://placehold.it/600x400&text=Fade+effect-Page-1">
</div>
<div class="item ">
<!-- you can add any content here-->
<img src="http://placehold.it/600x400&text=Fade+effect-Page-2">
</div>
</div>
<a class="carousel-control left btn-control " href="#carousel_fade" data-slide="prev">‹</a>
<a class="carousel-control right btn-control" href="#carousel_fade" data-slide="next">›</a>
</div>
</div>
</div>
</div>
<script>
$(function() {
$('.carousel').carousel({
interval: 7000
})
})
</script>
</body>
</html>

Categories