34
31

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CSS 流れるテロップを作る

Last updated at Posted at 2015-08-13

sample.gif

ニュース番組や駅の電光掲示板で見られる右から左へ流れるテロップを作りました。

テロップその1

html


<div id="wrap">
<div id="telop">
  <p id="flow-text">Hello World!</p>
</div>
</div>

CSS


#wrap{
  width: 100%;
}

#telop{
  position: relative;
  width: 100%;
  height: 1.3em; 
  font-size: 1.5em;
  overflow: hidden;
  background: #000;
  line-height: 1.3em;
}

#flow-text{
  position: absolute;
  top: 0;
  right: -20em; /* 文字数に合わせて変更 */
  color: #fff;
  white-space: nowrap;
  animation: flow 10s linear infinite;
}

@keyframes flow{
  from{
    right: -20em; /* 文字数に合わせて変更 */
  }

  to{
    right: 110%;
  }
}

テロップその2


<div class="telop">Hello world!</div>


.telop{
  white-space: nowrap;
  overflow: hidden;
  animation: flow 10s linear infinite;
}


@keyframes flow{
  from{
    text-indent: 100%;
  }

  to{
    /* 文字数に合わせて変更 */
    text-indent: -12em;
  }
}

34
31
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
31

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?