CSSだけで作るシンプルなニュースティッカー
Result
メディアサイト等でまだ見かけるやつ。
:hoverで一時停止するようにしています。
css
@keyframes ticker {
0% {
transform : translate ( 0 , 0 );
visibility : visible ;
}
100% {
transform : translate ( -100% , 0 );
}
}
.ticker- wrap {
position : fixed ;
bottom : 0 ;
width : 100% ;
overflow : hidden ;
height : 2 rem;
background-color : rgba ( 0 , 0 , 0 , 0.9 );
padding-left : 100% ;
box-sizing : content-box ;
}
.ticker- wrap .ticker {
display : inline-block ;
height : 2 rem;
line-height : 2 rem;
white-space : nowrap ;
padding-right : 100% ;
box-sizing : content-box ;
animation-iteration-count : infinite ;
animation-timing-function : linear ;
animation-name : ticker;
animation-duration : 30 s;
}
.ticker- wrap .ticker__item {
display : inline-block ;
padding : 0 2 rem;
font-size : 1 rem;
color : white ;
}
.ticker-wrap:hover .ticker{
animation-play-state : paused;
}
|
html
< div class = "ticker-wrap" >
< div class = "ticker" >
< div class = "ticker__item" >CSSだけでニュースティッカー</ div >
< div class = "ticker__item" >いろいろなニュース</ div >
< div class = "ticker__item" >CSSは難しい</ div >
< div class = "ticker__item" >今日はいい天気だ</ div >
</ div >
</ div >
|
via
Pure CSS Ticker (Horizontal)