I'm want animate 3 .svg
images:
<div class="sequence">
<img src="assets/img/1.svg"/>
<img src="assets/img/2.svg"/>
<img src="assets/img/3.svg"/>
</div>
and css
:
.sequence {
position: relative;
}
.sequence img {
position: absolute;
top: 0;
opacity: 0;
animation: cycle 0.3s steps(1) infinite;
}
@keyframes cycle {
0% { opacity: 1; }
33% { opacity: 0; }
}
.sequence img:nth-child(2) {
animation-delay: 0.1s;
}
.sequence img:nth-child(3) {
animation-delay: 0.2s;
}
but this way at some point animation starts slip and blink, with including of <img src="assets/img/1.svg" alt="" alt=""/>
in <a class="sequence" id="anm">
does not allows well align image in line with element center.
So, another way from background:
img{
width: 60px;
height: 60px;
border: 0px;
border-style: none; /*border-style: hidden;*/
outline: none;
animation: rotateImages 0.3s infinite;
}
@keyframes rotateImages {
0% { background: url("assets/img/1.svg"); }
32% { background: url("assets/img/1.svg"); }
33% { background: url("assets/img/2.svg"); }
65% { background: url("assets/img/2.svg"); }
66% { background: url("assets/img/3.svg"); }
100% { background: url("assets/img/3.svg"); }
}
with <img></img>
works without this lacks, but I can't figure out, how to remove thin black line around created element, border around pink squire, shown below, which appears with .svg
, .gif
, .png
. I've tried add border-width: 0px;
, just in case even border-color: white;
because my backgrounds is white, but it looks like it is something else. I'm not sure how to remove it:
Example:
https://jsfiddle.net/3gxpbauo/
.png-s
, which is same image of .svg
:
As I've noted, I want align it in one text central line with <label><h1><p id="nameblock">Text</p></h1></label>
. With <div id="container"></div>
, shown in Prajyot Tote answer, or as shown above with <a class="sequence" id="anm">
, (which also shows tag without outline successfully), in both cases aligns elements on separate lines, or with using of .inline{display:inline-block;}
in bottom line of the text. Here is <img>
and <div id="container"></div>
difference:
Solution:
So, the solution I found for my particular task with help of Prajyot Tote, based on answer, uses #container
without #img
with border: 0px;
for .inline
:
#container {
width: 72px;
height: 73px;
border: 0px;
animation: rotateImages 0.3s infinite;
}
.inline{display:inline-block;vertical-align: middle; border: 0px;}
@keyframes rotateImages {
0% { background: url("https://i.stack.imgur.com/d0tnz.png"); }
32% { background: url("https://i.stack.imgur.com/d0tnz.png"); }
33% { background: url("https://i.stack.imgur.com/elROb.png"); }
65% { background: url("https://i.stack.imgur.com/elROb.png"); }
66% { background: url("https://i.stack.imgur.com/O0fGg.png"); }
100% { background: url("https://i.stack.imgur.com/O0fGg.png"); }
}
<div class="inline">
<label><h1><p id="nameblock">Some text</p></h1></label>
</div>
<div id="container" class="inline"></div>