Can't move animation image vertical correct with #keyframe - html

I using a vertical sprite sheet in an animation with #keyframe.
I just can't get it to work correctly.
body{
background: brown;
}
.hi {
width: 117px;
height: 180px;
background-image: url("http://i.imgur.com/DxApxaV.png");
-webkit-animation: play .9s steps(8) infinite;
-moz-animation: play .9s steps(8) infinite;
-ms-animation: play .9s steps(8) infinite;
-o-animation: play .9s steps(8) infinite;
animation: play .9s steps(8) infinite;
}
#keyframes play {
from { background-position:0px; }
to { background-position:0px 1080px; }
}
<div class="hi"></div>
I tried using #keyframe with background-position-y axis to no avail.
It should be animation at 1 frame.

You just needed to change the steps to 6.
Basically speaking, steps is the number of sprites you are wanting to show over X time. So in this case, you only have 6, not 9.
I also changed it to use background-position.y.. note that having background-position: 0 0; is also good practice for when you come across more complex, grid sprite sheets.
body{
background: brown;
}
.hi {
width: 117px;
height: 180px;
background-image: url("http://i.imgur.com/DxApxaV.png");
background-position: 0 0;
-webkit-animation: play .9s steps(6) infinite;
-moz-animation: play .9s steps(6) infinite;
-ms-animation: play .9s steps(6) infinite;
-o-animation: play .9s steps(6) infinite;
animation: play .9s steps(6) infinite;
}
#keyframes play {
from { background-position-y:0px; }
to { background-position-y:1080px; }
}
<div class="hi"></div>

Related

How to Animate Multiple Background images?

I have a background made with 3 separate images i want to add rotate animation to all 3 images. If i animate the number-bg class all 3 images rotates. I want the rotate speed to be different for each image. what is the best approach to do that.
mycode
<style>
body {
height: 100%;
}
.number-bg {
height: 1000px;
background-image: url(https://i.imgur.com/BZrswvf.png),
url(https://i.imgur.com/XJ9zZeA.png),
url(https://i.imgur.com/RJDk9uS.png);
background-repeat: no-repeat;
background-position: center;
}
</style>
<body>
<div class="number-bg">
</div>
</body>
Image:
Check out the code to rotate each image at different speeds.
.number{height: 1000px;
background-repeat: no-repeat;
background-position: center;}
.no-9 {
background-image: url(https://i.imgur.com/BZrswvf.png);
-webkit-animation:spin 3s linear infinite;
-moz-animation:spin 3s linear infinite;
animation:spin 3s linear infinite
}
.no-6 {
background-image: url(https://i.imgur.com/XJ9zZeA.png);
-webkit-animation:spin 6s linear infinite;
-moz-animation:spin 6s linear infinite;
animation:spin 6s linear infinite
}
.no-3 {
background-image: url(https://i.imgur.com/RJDk9uS.png);
-webkit-animation:spin 1s linear infinite;
-moz-animation:spin 1s linear infinite;
animation:spin 1s linear infinite
}
#-moz-keyframes spin { 100% { -moz-transform: rotate(360deg); } }
#-webkit-keyframes spin { 100% { -webkit-transform: rotate(360deg); } }
#keyframes spin { 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); }
<div class="number no-9">
<div class="number no-6">
<div class="number no-3"></div>
</div>
</div>
Change the spin speeds as per your wish.

Need Assistance on Infinite Scrolling Banner on Wordpress

I have a question in regards to building an Infinite Scrolling Banner on a website I'm working on.
I made it by putting all my images on one image and having it scroll across the screen above my footer.
2 issues I'm having, the image is overlapping my outside container, I want it to just show up in the designated area for my content. Also my image isn't repeating it will scroll through the whole image and then start over, I was wondering if I can have the image run on repeat and no overlap my container outside it looks bad.
Here is the code I wrote for it, I would really appreciate any help from you guys, and I'd like to thank you in advance for helping me out.
This is the layout for the code.
<div class="photobanner" style="display: inline-block; height: 150px; width: 2500px; overflow: hidden;">
<img class="first" src="https://www.dcnevents.com/wp-content/uploads/2018/01/ScrollingSponsor-1.png" alt="" />
</div>
This is the styling I've done for the code:
#keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2150px;
}
}
#-moz-keyframes bannermove {
0% {
margin-left: 0px;
}
100% {
margin-left: -2150px;
}
}
#-webkit-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2150px;
}
}
#-ms-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2150px;
}
}
#-o-keyframes "bannermove" {
0% {
margin-left: 0px;
}
100% {
margin-left: -2150px;
}
}
.photobanner img{
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
transition: all 0.5s ease;
}
p .first{
-webkit-animation: bannermove 30s linear infinite;
-moz-animation: bannermove 30s linear infinite;
-ms-animation: bannermove 30s linear infinite;
-o-animation: bannermove 30s linear infinite;
animation: bannermove 30s linear infinite;
display:inline-block;
}

How to have two css animations in one tag

I am working with css animations and I have a series of animations with different css tags. I start at #water then go to other animations then I want to go back to #water with a different animation. This is my code:
#water {
position: relative;
left: 48px;
z-index: 1;
opacity: 0;
width: 197px;
-webkit-animation: squeez 2s 1s 1 forwards;
-moz-animation: squeez 2s 1s 1 forwards;
-o-animation: squeez 2s 1s 1 forwards;
-webkit-animation: fadeOut 10s 10s 1 forwards;
-moz-animation: fadeOut 10s 10s 1 forwards;
-o-animation: fadeOut 10s 10s 1 forwards;
}
It does not work how I want it to. The code is disregarding the first animation "squeez" and only doing the animation "fadeOut" which messes everything up. Any ideas on how to make this work?
You can comma-separate your animations, so you could do:
-webkit-animation: squeez 2s 1s 1 forwards, fadeOut 10s 10s 1 forwards;
-moz-animation: squeez 2s 1s 1 forwards, fadeOut 10s 10s 1 forwards;
-o-animation: squeez 2s 1s 1 forwards, fadeOut 10s 10s 1 forwards;
animation: squeez 2s 1s 1 forwards, fadeOut 10s 10s 1 forwards;
div {
-webkit-animation: squeez 2s 1s forwards, fadeOut 10s 5s forwards;
animation: squeez 2s 1s forwards, fadeOut 10s 5s forwards;
height: 100px;
width: 100px;
background: #F00;
}
#-webkit-keyframes squeez {
from {
width: 100px;
}
to {
width: 20px;
}
}
#-webkit-keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0.5;
}
}
#keyframes squeez {
from {
width: 100px;
}
to {
width: 20px;
}
}
#keyframes fadeOut {
from {
opacity: 1;
}
to {
opacity: 0.5;
}
}
<div>
</div>

Background Crossfade

I am working on a website (early stages) and I'm having severe difficulties applying a background crossfade in the white-background area (I would like to have a few images auto-rotating on the background, completely filling it).
As per the HTML code, I should be fine working with class .main-container in the CSS however, this changes nothing...
I would sincerely appreciate your help, I'm self-taught in HTML+CSS and I just need guidance for the right steps to take.
What would you recommend?
Many thanks in advance!
(update)
I decided to go for the Tympanus.net solution.
Which has been badly implemented to http://www.marcocarlo.com/mimosa/index.html
Here's the CSS code:
.cb-slideshow,
.cb-slideshow:after {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
z-index: 0;
}
.cb-slideshow:after {
content: '';
background: transparent url(images/pattern.png) repeat top left;
background-size:cover;
}
.cb-slideshow li span {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
color: transparent;
background-size: cover;
background-position: 50% 50%;
background-repeat: none;
opacity: 0;
z-index: 0;
-webkit-backface-visibility: hidden;
-webkit-animation: imageAnimation 36s linear infinite 0s;
-moz-animation: imageAnimation 36s linear infinite 0s;
-o-animation: imageAnimation 36s linear infinite 0s;
-ms-animation: imageAnimation 36s linear infinite 0s;
animation: imageAnimation 36s linear infinite 0s;
}
.cb-slideshow li div {
z-index: 1000;
position: absolute;
bottom: 30px;
left: 0px;
width: 100%;
text-align: center;
opacity: 0;
color: #fff;
-webkit-animation: titleAnimation 18s linear infinite 0s;
-moz-animation: titleAnimation 18s linear infinite 0s;
-o-animation: titleAnimation 18s linear infinite 0s;
-ms-animation: titleAnimation 18s linear infinite 0s;
animation: titleAnimation 18s linear infinite 0s;
}
What can I do so it is on display in the white background area (fully covering it?)
Many thanks in advance!
You can try looking for some existing guides. Or maybe look for some existing image sliders with crossfade transitions. If you are willing to write your own crossfade though, you can use background-size: cover to fill entire areas (example)

Experimenting with bgrnd img scroll, to no avail

Here is the CSS:
body {
background-image: url(SMback.jpg);
color: #ecf2f9;
text-align: center;
-webkit-animation: bgscroll 20s infinite linear;
-moz-animation: bgscroll 20s infinite linear;
-ms-animation: bgscroll 20s infinite linear;
-o-animation: bgscroll 20s infinite linear;
}
I have no divs set up, just a simple HTML skeleton. The image is appearing without the scroll. What can I be doing better here?
Did you remember to define your keyframes for the bgscroll animation?
#keyframes bgscroll
{
from {background-position:0 0;}
to {background-position:0 200px;}
}
Here's a fiddle to help you out: http://jsfiddle.net/JC9e8/