TV style information bar (similar to <Marquee>tag)

Asked

Viewed 200 times

1

I need to make an information bar style of the TV channels that keeps passing from right to left. I have the text that comes from the database and as it is a long text I would need it to be looped. I’ll use it on a web page.

inserir a descrição da imagem aqui

  • Buddy if you don’t post the code you already have, you won’t get help!

  • Without posting the code is complicated, I could even suggest you use something unlikely like <marquee> in your code for example...

  • Stackoverflow does not provide ready-made code

  • @Ricardopunctual This element is obsolete. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/marquee

  • @Valdeirpsr I know, so I said "suggest using something unlikely", I don’t think you understand what I mean :)

2 answers

1


As you did not put more details in the question follows a simple model that can serve you. Basically you need to create a "container" with overflow:hidden and do the animation with @keyframes

.txt {
    width: 10em;
    height: 1.5em;
    background-color: red;
    color: #fff;
    font-family: sans-serif;
    font-size: 1rem;
    line-height: 1.5em;
    padding: 0.5em;
    white-space: nowrap;
    overflow: hidden;
}
.txt span {
    padding-left: 100%;
    display: inline-block;
    animation: texto 10s linear infinite;
}
@keyframes texto {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(-100%, 0);
    }
}
<div class="txt"><span>URGENTE!!! - <strong>Bolso Mito vai te pegar</strong> se vc não colocar o código na pergunta!</span></div>

-1

It has the plugin jquery.Marquee that uses css3 to make the animation, as the element Marquee is obsolete I think this is the best way. I found in codepen an example https://codepen.io/aamirafridi/pen/qgutw

$('.marquee').marquee({
    //speed in milliseconds of the marquee
    duration: 5000,
    //gap in pixels between the tickers
    gap: 50,
    //time in milliseconds before the marquee will start animating
    delayBeforeStart: 0,
    //'left' or 'right'
    direction: 'left',
    //true or false - should the marquee be duplicated to show an effect of continues flow
    duplicated: true
});
.marquee {
  width: 300px;
  overflow: hidden;
  border: 1px solid #ccc;
  background: #ccc;
}
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//cdn.jsdelivr.net/jquery.marquee/1.3.1/jquery.marquee.min.js"></script>

<div class="marquee">jQuery marquee is the best marquee plugin in the world</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.