Issue
I have a problem with this code. I want to apply a marquee effect to this words with continues animation. In my result, at the 100% Keyframe, the animation return to 0 and the effect is orrible! I want animation to be fully responsive. Thank u very much!
With this video you can see the error -> VIDEO
var elements = $('ul.tithome li').length;
for(var i=0;i < elements; i++){
$(".tithome").clone().prependTo( ".scorri" );
};
var liEle = [];
var liEle = $(".tithome li");
.cont{
width: 100%;
overflow: hidden;
}
.scorri{
position:relative;
display: flex;
width: 100%;
animation-name: marquee;
animation-duration: 20s;
animation-iteration-count: infinite;
animation-timing-function: linear;
justify-content: space-between;
}
.tithome{
display: contents;
}
.tithome li{
width: fit-content;
display: inline-block;
list-style: none;
padding-right: 30px;
font-size: 40px;
}
@keyframes marquee {
0% { left: 0; }
100% {left: -88.79%;}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="cont">
<div class="scorri">
<ul class="tithome">
<li>Governance</li>
<li>HR</li>
<li>Sales</li>
</ul>
</div>
</div>
Solution
You can animate a transform
property instead of left
:
var elements = $('ul.tithome li').length;
for(var i=0;i < elements; i++){
$(".tithome").clone().prependTo( ".scorri" );
};
var liEle = [];
var liEle = $(".tithome li");
.cont{
width: 100%;
overflow: hidden;
}
.scorri{
position: relative;
display: flex;
width: 100%;
justify-content: space-between;
}
.tithome{
animation-name: marquee;
animation-duration: 5s;
animation-iteration-count: infinite;
animation-timing-function: linear;
flex-shrink: 0;
}
.tithome li{
width: fit-content;
display: inline-block;
list-style: none;
padding-right: 30px;
font-size: 40px;
}
@keyframes marquee {
0% { transform: translateX(0); }
100% { transform: translateX(-100%); }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="cont">
<div class="scorri">
<ul class="tithome">
<li>Governance</li>
<li>HR</li>
<li>Sales</li>
</ul>
</div>
</div>
Answered By - Yann Armelin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.