admin管理员组文章数量:1431224
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=".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>
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./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>
Share
Improve this question
edited May 6, 2020 at 8:06
Pasquale Bassolillo
asked May 5, 2020 at 18:46
Pasquale BassolilloPasquale Bassolillo
331 silver badge5 bronze badges
2
- What does without with no gap mean? Also, your code does continuously animate. As for being fully responsive, what is your desire? – Scott Marcus Commented May 5, 2020 at 18:50
- Hi Scott, sorry for my English. the gap between the words isn't problem. if you see the animation until the end, the words doesn't flow infinitely, but stops at a certain instant of time and starts again from the beginning. – Pasquale Bassolillo Commented May 5, 2020 at 18:55
2 Answers
Reset to default 5You 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./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>
i just saw this post. It saves my time. Thanks a lot. By the way i create a pen for this and just remove some empty spaces from list and change it to scss.
if someone needs it can find from this address
https://codepen.io/tsdln/pen/LYOLdXQ
var elements = $('ul.list li').length;
本文标签: javascriptInfinite Marquee responsive no gapStack Overflow
版权声明:本文标题:javascript - Infinite Marquee responsive no gap - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745534499a2662210.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论