animate.css animating distance - html

I am using animate.css for a login form. It works except not the way I want it to work. Currently I am using fadeInDown but it fades in down from a longer distance that I want. It fades in from off the viewport versus just fading in about 20px. I hope that makes sense.
https://daneden.github.io/animate.css/
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.min.css" rel="stylesheet" />
<div id="login">
<div class="row animated fadeInDown">
<img src="logo.png"/>
<input type="text">
<input type="password">
</div>
</div>

Just overwrite the default fadeInDown animation to what ever you like.
If you take a look at the source on GitHub - animate.css/source/fading_entrances/fadeInDown.css you'll see that it is just a simple #keyframes rule. Just copy that and change the transform property to your needs.
In your case like so:
transform: translate3d(0, -20px, 0);
Here is an example changing the fadeInDown animation to appear from left to right instead of going from top to bottom, which makes no sense at all, but just to show you that it can be changed.
You could as well do a custom build and add your own animations or a helper class to change the offset.
#import url('https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.1/animate.min.css');
#keyframes fadeInDown {
from {
opacity: 0;
transform: translate3d(-100%, 0, 0);
}
to {
opacity: 1;
transform: none;
}
}
<div id="login">
<div class="row animated fadeInDown">
<input type="text">
<input type="password">
</div>
</div>

Related

How to achieve parallax effect with grandchildren

I've achieved the parallaxing background effect a few times before on codepen's and small, experimental projects.
This is my favorite tutorial on it - https://keithclark.co.uk/articles/pure-css-parallax-websites/
Here's the markup from the referenced tutorial:
<div class="parallax">
<div class="parallax__layer parallax__layer--back">
...
</div>
<div class="parallax__layer parallax__layer--base">
...
</div>
</div>
And the vital CSS bits:
.parallax {
...
perspective: 1px;
}
.parallax__layer--base {
transform: translateZ(0);
}
.parallax__layer--back {
transform: translateZ(-1px);
}
Basically - The .parallax element has a perspective, which essentially means it can view things in 3d space.
The .parallax__layer--base(which is the foreground layer) is placed at 0 on the z-axis. So it hasn't moved from it's origin.
The .parallax__layer--back (the background layer) is placed one pixel back on the z axis.
So now, when you scroll through the .parallax element, you can see these background and foreground layers moving in a 3d space, which gives the parallax effect.
But it only works if you are scrolling through the .parallax element - What about on a full-sized, robust page?
<div class='home'>
...
<div class="parallax">
<div class="parallax__layer parallax__layer--back">
...
</div>
<div class="parallax__layer parallax__layer--base">
...
</div>
</div>
...
</div>
The css and markup haven't changed. But now I'm scrolling through the .home element, and not the .parallax element. The foreground and background layers are still in a 3d space, but it's only relative to the .perspective element.
Is there a way to somehow pass that perspective down to the homepages grandchildren, or great grandchildren? Or do I need to divide my entire page into foreground and background sections in order to achieve this effect?
I came up with a "hacky" way of achieving this with JavaScript.
Here's a rundown of the steps (you may call it the algorithm):
listen for the window scroll event
wait until the parallax container (parent of what you defined as base and back) is in view
in my case, I fixed back and changed top value of base over a transition duration.
Here's my implementation (specific to my use case):
/**
* hacky parallax effect
*/
const viewportHeight =
'innerHeight' in window
? window.innerHeight
: document.documentElement.offsetHeight
const headerHeight = document.querySelector('header').offsetHeight
window.onscroll = () => {
const preFooterPosition = document
.querySelector('.pre-footer')
.getBoundingClientRect()
/** start parallax when pre-footer is in view */
if (
preFooterPosition.top <= headerHeight &&
preFooterPosition.bottom >= viewportHeight
) {
// parallax
document.querySelector('.content').classList.add('transform-content')
} else {
// reverse parallax
document
.querySelector('.content')
.classList.remove('transform-content')
}
}
.content {
display: flex;
flex-direction: column;
flex: 1;
z-index: 1;
position: relative;
top: 0;
transition: top 1s ease;
}
.transform-content {
top: -5rem;
}
.watermark {
position: absolute;
z-index: 0;
flex: 1;
display: flex;
}
<template>
<section class="pre-footer">
<div class="wrapper">
<div class="watermark">
<SVGIcon class="watermark-left" icon="LearnLongShort" />
<SVGIcon class="watermark-right" icon="FreeEducation" />
</div>
<div class="content">
<div class="content-left content-wrapper">
<div>
<h3 class="title">Evidence base</h3>
<div class="body">
<p>The Academy of Medical Cannabis Evidence Base is an advanced referencing tool for CBMP research. Containing the history of research to date and all emerging findings, this cutting-edge engine underpins our learning content.</p>
</div>
<WhiteButton text="View database" />
</div>
</div>
<div class="content-right content-wrapper">
<div>
<h3 class="title">White Papers</h3>
<div class="body">
<p>Alongside our learning platform, The Academy publishes a series of authoritative papers discussing the core topics and themes related to CBMPs. Register to view and download the archive.</p>
</div>
<WhiteButton text="Archive" />
</div>
</div>
</div>
</div>
</section>
</template>
I hope that helps. Let me know when you come up with a better solution.
In the meantime, I'm pushing this.
Cheers!

Fade in of an input textbox

I'm trying to fade in a textbox via CSS keyframes:
.otherAnim{
animation-delay:11s;
animation-duration:2s;
animation-iteration-count:1;
animation-fill-mode: forwards;
}
#keyframes Appear{
from {opacity:0;}
to {opacity:1;}
}
<div class="col" style="width:30%;height:100%">
<h2>some text</h2>
<h2 class="otherAnim" style="animation-name:Appear;opacity:0;">some text: </h2>
<input type="text" id=myInput class="otherAnim inputSoFar" style="animation-name:Appear;float:left;height:45px;opacity:0;">
</div>
This works on JSFiddle, but not in my local view of the page (Chrome 57). The weird thing for me is that if I inspect the element, the otherAnim class has dissapeared. This doesn't happen in JSFiddle. I'm using w3.css, but it still works if I load it as a external resource in JSFiddle.
What am I possibly missing ?
Don't put the animation-name property in inline style. You have to put it in the style tag or a linked css file.

How to make text to appear into image box?

I started to make my own gallery, and have one thing that cant resolve..
I want text that appear in part "UNSEREN DIENSTLEISTUNGEN" from homepage, from left in this site, to be showed in similar way in other images, but with image style like other pages (sppinin images).
This is code from first image:
<div class="serviceQuad">
<div class="tr-slideImgOut"><img src="/files/hjung2014/img/holzbau.jpg" alt="Holzbau" /></div>
<span class="figure tr-slideIn" href="">{{insert_content::26}}</span></div>
and this is image style from other images, (like i want to be, but text to appear inside box)
<div class="serviceQuad">
<div class="morph"><img src="/files/hjung2014/img/holzbau.jpg" alt="Holzbau" /></div>
<span class="morph" href="">{{insert_content::26}}</span></div>
Thanks for any help.
You can just add class with changed rotation style.
For example add fullRotate class like this:
HTML
<div class="serviceQuad">
<div class="tr-slideImgOut fullRotate">
<img src="/files/hjung2014/img/holzbau.jpg" alt="Holzbau" />
</div>
<span class="figure tr-slideIn" href="">{{insert_content::26}}</span>
</div>
And then add new rotation style for it:
CSS
.serviceQuad:hover .tr-slideImgOut.fullRotate img {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg)
}

transform3d not changing after alteration

This is the default code:
<div style="position: absolute; left: 0px; top: 0px; transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); width: 337px; height:480px; opacity: 1;" class="events-item one-four onsite technical isotope-item">
<div class="events-image"> <img src="img/01_th.jpg" alt="events 1"> </div>
<a href="" title="MYB V3.0" class="open-project">
<div class="project-overlay">
<div class="project-info">
<div class="zoom-icon"></div>
<h4 class="project-name">MYB V3.0</h4>
<p class="project-categories">Onsite</p>
</div>
</div>
</a>
</div>
When i altered it as:
<div style="position: absolute; left: 337px; top: 0px; transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); width: 337px; height:480px; opacity: 1;" class="events-item one-four onsite technical isotope-item">
<div class="events-image"> <img src="img/01_th.jpg" alt="events 1"> </div>
<a href="" title="MYB V3.0" class="open-project">
<div class="project-overlay">
<div class="project-info">
<div class="zoom-icon"></div>
<h4 class="project-name">MYB V3.0</h4>
<p class="project-categories">Onsite</p>
</div>
</div>
</a>
</div>
Nothing changes
When I inspect the element in the browser it shows the default code
like this:
Anyone Please help
So I just made a mockup with the code you have and its difficult to tell what your problem is exactly with such a small sample, The elements surrounding this code, and the css classes you did not provide for us to see could very well be making a difference that I'm not seeing however this is what I discovered.
You have assigned a width: 337pxbut there is no height on the element, therefore it does not show up at all. When I gave a height: 200px to the element, and changed the x Position in the translate3d to 337px. The object did shift right337px`.
Once again, given the small code sample you provided, for all I know you already assign a height in one of the many classes that is at the end of your tag, for more detailed help please provide more info for me and I can take a deeper look.
Good luck!
Side Note:
Good CSS practice is to avoid using the style attribute for anything other than prototyping, creating a CSS class is more modular and allows for better code-reuse.
UPDATE
I ran the new code you posted in a google chrome browser. The transform3d is acting as expected, and moving the xPos of the div by 337px.
Here are some screenshots:
Result without the 337px offset
Result with the 337px offset
As you can see the offset that you are adding is happening, but it seems that transform3d is not a universally supported tag yet, if an offset affect is what you want to achieve there are many more traditional ways to achieve this such as left: 337px

Rotating image via CSS

I am working on an app that uses Bootstrap. You can see it for yourself here. When a user clicks a link, I want it to rotate. The code is very small. It looks like this:
<div class="form-group">
<ul class="list-inline">
<li><button class="btn btn-link"><span class="glyphicon glyphicon-chevron-down"></span></button></li>
<li><h5>category</h5></li>
</ul>
</div>
When a user clicks the "v" I want it to animate from "v" to ">". In other words, I want the chevron to rotate counter-clockwise 90 degrees when someone clicks it. After looking at the powerful features in CSS 3, it looks like there is a way to do this using pure CSS. Am I correct, if so, how?
Try this:
DEMO
<div class="form-group">
<ul class="list-inline">
<li><button class="btn btn-link"><span class="glyphicon glyphicon-chevron-down"></span></button></li>
<li><h5>category</h5></li>
</ul>
</div>
SCRIPT:
$('.glyphicon').on('click', function(){
$(this).toggleClass('glyphicon-chevron-down glyphicon-chevron-right');
});
To rotate an element using CSS you can simply use transform: rotate(-90deg)
However, this will not rotate it on click just yet. You will probably need javascript for that. One way to do it (using jquery, since bootstrap already requires it):
CSS:
.rotated {
transform: rotate(-90deg);
}
JS:
$('.yourElement').click(function() {
$(this).toggleClass('rotated');
});
The 'toggleClass' will make sure the rotation is reverted when you click it again. Otherwise, just use 'addClass' to only use it once.
edit
As pointed out by Harry, you could also use the already present 'icon-chevron-right' in a similar fashion:
$('.yourElement').click(function() {
$(this).toggleClass('icon-chevron-down icon-chevron-right');
});
As long as your html started with only one of those two classes, this code will always remove one and add the other.
Css :
.spinEffect{
-webkit-animation: spin 0.5s infinite linear;
}
jQuery :
$(function(){
$(".whatIsClicked").click(function(){
$("#yourDiv").addClass("spinEffect");
});
});
You can use a simple script like this.
Script:-
$(document).ready(function(){
$( ".btn.btn-link" ).click(function() {
$(this).toggleClass( "rotate" );
});
})
css:-
.rotate{
-ms-transform: rotate(180deg); /* IE 9 */
-webkit-transform: rotate(180deg); /* Chrome, Safari, Opera */
transform: rotate(180deg);
}
html:-
<div class="form-group">
<ul class="list-inline">
<li><button class="btn btn-link"><span class="glyphicon glyphicon-chevron-down"></span></button></li>
<li><h5>category</h5></li>
</ul>
</div>
Hope it eill work for you!