Trying to have a div expand on page load:
#box {
width: 10px; height: 10px;
-moz-animation: expandwidth 1s forwards;
animation: expandwidth 1s forwards;
}
while the following animation works as expected in firefox:
#-moz-keyframes expandwidth{
100% {width: 60%; min-width: 800px;}
}
this won't quite work in IE 11:
#keyframes expandwidth{
100% {width: 60%; min-width: 800px;}
}
in fact, while it does expand to 60% length, it does not take into account the min-width requirement, which can easily be seen as I shrink the browser size horizontally. In firefox however, it does not shrink under 800px, as intended. Am I doing something wrong? I cannot seem to find anything regarding min-width being unsupported in IE animations. Also note that I am looking for a css fix only. Thanks.
Edit: see http://jsfiddle.net/qyan20k9/
works for me in FFX 31.0 but not in IE 11
I've tested this in IE11, Chrome 38 (64bit)& FF31 and it seems to work is you establish a min-width to start with.
JSfiddle Demo
#box {
width: 10px;
height: 30px;
min-width:10px; /* here */
-moz-animation: expandwidth 1s forwards;
-webkit-animation: expandwidth 1s forwards;
animation: expandwidth 1s forwards;
background: grey;
}
#-webkit-keyframes expandwidth {
100% {
width: 60%;
min-width: 800px;
}
}
#-moz-keyframes expandwidth {
100% {
width: 60%;
min-width: 800px;
}
}
#keyframes expandwidth {
100% {
width: 60%;
min-width: 800px;
}
}
Related
I'm working on a project where I want to have two animation with one following the other after a delay. I've gotten the two animation on the same line with one following after a delay, but I can't seem to get it work perfectly. The issue that I am having is that the first animation is starting after 0%/0vw, so it's show the animation start instead of it coming from off the page. I would really appreciate any help or advice on how to get this to work. Thank you!
.announcement {
justify-content: right;
align-items: center;
display: flex;
}
.announce {
font-size: 1.3rem;
position: relative;
/* animation: mymove 20s infinite;*/
/* animation-timing-function: linear;*/
animation: linear 15s mymove infinite;
}
.announce2 {
font-size: 1.3rem;
position: relative;
/* animation: mymove 20s infinite;*/
/* animation-timing-function: linear;*/
animation: linear 15s mymove2 infinite;
animation-delay: 5s;
}
#keyframes mymove {
from {right: 0vw;}
50% {right: 50vw !important;} /* ignored */
to {right: 100vw;}
}
#keyframes mymove2 {
from {right: 0vw;}
50% {right: 50vw !important;} /* ignored */
to {right: 100vw;}
}
<div class="announcement">
<div class="announce">
Hello
</div>
<div class="announce2">
Hello
</div>
</div>
To get the announcement off the screen to the right it needs to not only be positioned right: 0 but also to move further to the right by its own width. This can be achieved with a translation of 100%.
As an example, this snippet gives both announcements the same animation and other settings - apart from giving announement2 the animation delay.
The parent element has overflow hidden, and the body is given margin 0 to ensure that the announcements go fully from the right to the left.
body {
margin: 0;
}
.announcement {
justify-content: right;
align-items: center;
display: flex;
overflow: hidden;
}
.announce,
.announce2 {
font-size: 1.3rem;
position: relative;
animation: linear 15s mymove infinite;
right: 0;
transform: translateX(100%);
}
.announce2 {
animation-delay: 5s;
}
#keyframes mymove {
to {
right: 100vw;
transform: translateX(0%);
}
}
<div class="announcement">
<div class="announce">
Hello
</div>
<div class="announce2">
Hello
</div>
</div>
Note: if what you are wanting is an evenly spaced continuous flow then you might like to search for 'marquee' on StackOverflow - not the HTML tag which is deprecated but continuous rotating banner.
I am working on a new website, but when my friend tested it on firefox one of the features was not working.
We found out the css is not working in firefox but it does work in Chrome.
The whole code: https://jsfiddle.net/wvkL6d2b/
We tried
-webkit- and -ms-
#separator{ width: 10px!important; max-width: 60px!important; height: 10px; background:red;}
#keyframes in-out {
from { width: 10px;
}
10%, 100% {
width: 60px;
}
to{ width: 60px; }
}
#separator {
animation-name: in-out;
animation-duration: 8s;
animation-iteration-count: infinite;
animation-timing-function: linear;
animation-delay: 2s;
}
I am trying to get it to work on both browsers
There are so many mistakes in the CSS properties you have written. Please find the updated code here in fiddle.
These are supposed to be properties to use.
#separator {
height: 10px;
background: red;
-webkit-animation: mymove 5s infinite; /* Safari 4.0 - 8.0 */
animation: mymove 5s infinite;
}
#-webkit-keyframes mymove {
0% { width: 10px; }
100% { width: 100px; }
}
/* Standard syntax */
#keyframes mymove {
0% { width: 10px; }
100% { width: 100px; }
}
It's not working because you have declared the wrong property.
The declaration you need for firefox is just animation. Only Chrome and Safari need the -webkit- prefix for this CSS3 effect.
So your code would be:
-webkit-animation:slideshow 21s infinite;
animation:slideshow 21s infinite;
Ref:
http://www.w3schools.com/css3/css3_animations.asp
If I have two lines of text one on top of the other. Content of each line is dynamic.
Is there a way to set animation speed in pixels per second? So that line would scroll with same speed regardless of their length?
Example of the situation:
div {
width: 50%;
padding-left: 10%;
float: left;
height: 50px;
overflow: hidden;
position: relative;
}
#line1 {
background-color: green;
}
#line2 {
background-color: yellow;
}
h4 {
position: absolute;
height: 100%;
margin: 0;
line-height: 50px;
text-align: left;
/* Apply animation to this element */
/* Animation delay 0.5s */
-moz-animation: line-scroll 15s linear 0.5s infinite;
-webkit-animation: line-scroll 15s linear 0.5s infinite;
animation: line-scroll 15s linear 0.5s infinite;
}
#line1 h4 {
/* width must be big enought to fit in whole text othrwise
whole text will not scroll into view */
width: 200%;
}
#line2 h4 {
/* width must be big enought to fit in whole text othrwise
whole text will not scroll into view */
width: 600%;
}
#keyframes line-scroll {
0% {
-moz-transform: translateX(0%);
/* Firefox bug fix */
-webkit-transform: translateX(0%);
/* Firefox bug fix */
transform: translateX(0%);
}
100% {
-moz-transform: translateX(-100%);
/* Firefox bug fix */
-webkit-transform: translateX(-100%);
/* Firefox bug fix */
transform: translateX(-100%);
}
}
<div id="line1">
<h4>I don't want to come off as arrogant here, but I'm the greatest botanist on this planet.</h4>
</div>
<div id="line2">
<h4>Every human being has a basic instinct: to help each other out. If a hiker gets lost in the mountains, people will coordinate a search. If a train crashes, people will line up to give blood. If an earthquake levels a city, people all over the world will send emergency supplies. This is so fundamentally human that it's found in every culture without exception. Yes, there are assholes who just don't care, but they're massively outnumbered by the people who do. ~ Mark Watney, The Martian</h4>
</div>
Means of AngularJS directive and CSS are welcome.
You can use JQuery (javascript) to get the width of headings and than calculate the duration based on the width i.e duration per pixel
width() method of jquery is used to get width of the headings.
I calculate the the duration as follows:
1s = 20px
Therefore 100px = 100/20
= 5s
You can increase the denominator (see the number10) in var dur1=Math.ceil(w1/10) to speed up the scrolling.
Here is the code
//getting the width of both the headings
var w1=$("#line1>h4").width();
var w2=$("#line2>h4").width();
//calculating the duration of the animation dynamically based on the width
var dur1=Math.ceil(w1/10);
var dur2=Math.ceil(w2/10);
//setting the duration dynamically
$("#line1>h4").css("animation-duration",dur1+"s");
$("#line2>h4").css("animation-duration",dur2+"s");
div {
width: 50%;
padding-left: 10%;
float: left;
height: 50px;
overflow: hidden;
position: relative;
}
#line1 {
background-color: green;
}
#line2 {
background-color: yellow;
}
h4 {
position: absolute;
height: 100%;
margin: 0;
line-height: 50px;
text-align: left;
/* Apply animation to this element */
/* Animation delay 0.5s */
-moz-animation: line-scroll 15s linear 0.5s infinite;
-webkit-animation: line-scroll 15s linear 0.5s infinite;
animation: line-scroll 15s linear 0.5s infinite;
}
#line1 h4 {
/* width must be big enought to fit in whole text othrwise
whole text will not scroll into view */
width: 200%;
}
#line2 h4 {
/* width must be big enought to fit in whole text othrwise
whole text will not scroll into view */
width: 600%;
}
#keyframes line-scroll {
0% {
-moz-transform: translateX(0%);
/* Firefox bug fix */
-webkit-transform: translateX(0%);
/* Firefox bug fix */
transform: translateX(0%);
}
100% {
-moz-transform: translateX(-100%);
/* Firefox bug fix */
-webkit-transform: translateX(-100%);
/* Firefox bug fix */
transform: translateX(-100%);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="line1">
<h4>I don't want to come off as arrogant here, but I'm the greatest botanist on this planet.</h4>
</div>
<div id="line2">
<h4>Every human being has a basic instinct: to help each other out. If a hiker gets lost in the mountains, people will coordinate a search. If a train crashes, people will line up to give blood. If an earthquake levels a city, people all over the world will send emergency supplies. This is so fundamentally human that it's found in every culture without exception. Yes, there are assholes who just don't care, but they're massively outnumbered by the people who do. ~ Mark Watney, The Martian</h4>
</div>
In CSS you must provide the animation duration in time units, which is currently seconds / miliseconds.
You could, however, adapt the width of the transition by switching from a %-value to px-values like shown below:
div {
width: 50%;
padding-left: 10%;
float: left;
height: 50px;
overflow: hidden;
position: relative;
}
#line1 {
background-color: green;
}
#line2 {
background-color: yellow;
}
h4 {
position: absolute;
height: 100%;
margin: 0;
line-height: 50px;
text-align: left;
/* Apply animation to this element */
/* Animation delay 0.5s */
-moz-animation: line-scroll 15s linear 0.5s infinite;
-webkit-animation: line-scroll 15s linear 0.5s infinite;
animation: line-scroll 15s linear 0.5s infinite;
}
#line1 h4 {
/* width must be big enought to fit in whole text othrwise
whole text will not scroll into view */
width: 200%;
}
#line2 h4 {
/* width must be big enought to fit in whole text othrwise
whole text will not scroll into view */
width: 600%;
}
#keyframes line-scroll {
0% {
-moz-transform: translateX(0%);
/* Firefox bug fix */
-webkit-transform: translateX(0%);
/* Firefox bug fix */
transform: translateX(0%);
}
100% {
-moz-transform: translateX(-1000px);
/* Firefox bug fix */
-webkit-transform: translateX(-1000px);
/* Firefox bug fix */
transform: translateX(-1000px);
}
}
<div id="line1">
<h4>I don't want to come off as arrogant here, but I'm the greatest botanist on this planet.</h4>
</div>
<div id="line2">
<h4>Every human being has a basic instinct: to help each other out. If a hiker gets lost in the mountains, people will coordinate a search. If a train crashes, people will line up to give blood. If an earthquake levels a city, people all over the world will send emergency supplies. This is so fundamentally human that it's found in every culture without exception. Yes, there are assholes who just don't care, but they're massively outnumbered by the people who do. ~ Mark Watney, The Martian</h4>
</div>
I'm pretty new at web development, but I'm trying to animate my logo (represented in the codepen by the blue rectangle) for my portfolio website. There are actually two animations. 1. fadein: the logo fades in from the top 2. shrink: (after a 3 second delay) the logo moves from the middle of the page to the top left corner and shrinks a bit.
If you open the pen in safari you'll see it working, but if you open it in chrome or firefox (given that you change the -webkit-) it sort of blends the two animations into one.
Any ideas to why this might happen en how to fix it?
codepen
div
{
height: 150px;
width: 170px;
position: fixed;
background-color: blue;
-webkit-animation-duration: 2s, 2s;
-webkit-animation-name: fadein, shrink;
-webkit-animation-delay: 0, 3s;
-webkit-animation-fill-mode: forwards;
}
#-webkit-keyframes fadein
{
0% {opacity: 0; top: 30%; left: 50%; margin-top: -75px; margin-left: -85px;}
100% {opacity: 1; top: 50%; left: 50%; margin-top: -75px; margin-left: -85px;}
}
#-webkit-keyframes shrink
{
0% {top: 50%; left: 50%; margin-top: -75px; margin-left: -85px;}
100% {top: 50px; left: 20px; margin: 0; width: 84px; height: 74px;}
}
Thanks!
The problem is with your animation delay. I'm not sure if it's bugged or as specification, but it doesn't work if you don't pass a unit, not even for zero.
-webkit-animation-delay: 0s, 3s;
That is, using 0s instead of 0.
I can't seem to get the animation timing right on this
http://codepen.io/anon/pen/ZYMgqE
.spinner {
width: 36px;
height: 36px;
background: url('http://i.imgur.com/CYiaWsF.png') top center;
animation: play 1s steps(10) infinite;
}
#keyframes play {
100% { background-position: 0px -2844px; }
}
I have tried numerous combinations, but it always comes out looking like a film reel.
Am I doing something wrong? Did I misunderstand CSS sprite animations?
Your math is off..I think.
The image is, apparently, 2844 px tall...so the number of steps should be the height divided by the element height
2844 / 36 = 79
.spinner {
width: 36px;
height: 36px;
background: url('http://i.imgur.com/CYiaWsF.png') top center;
-webkit-animation: play 1s steps(79) infinite;
animation: play 1s steps(79) infinite;
}
#-webkit-keyframes play {
100% {
background-position: 0px -2844px;
}
}
#keyframes play {
100% {
background-position: 0px -2844px;
}
}
<div class="spinner"></div>