Vertiaclly-scrolling list that has the appearance of fading in and out.
A Pen by Matt Soria on CodePen.
| <div class="box"> | |
| <ul> | |
| <li class="item-1">One</li> | |
| <li class="item-2">Two</li> | |
| <li class="item-3">Three</li> | |
| <li class="item-4">Four</li> | |
| <li class="item-5">Five</li> | |
| <li class="item-6">One</li> | |
| </ul> | |
| </div> |
| html { | |
| height: 100%; | |
| } | |
| body { | |
| height: 100%; | |
| display: flex; | |
| font-size: 18px; | |
| letter-spacing: .02em; | |
| text-transform: uppercase; | |
| } | |
| // Varaibles | |
| $item-count: 6; | |
| $item: 1 / $item-count; | |
| .box { | |
| height: 40px; | |
| margin: auto; | |
| overflow: hidden; | |
| position: relative; | |
| &::before { | |
| top: 0; | |
| left: 0; | |
| z-index: 1; | |
| width: 100%; | |
| content: ''; | |
| height: 10px; | |
| position: absolute; | |
| background: linear-gradient(180deg, rgba(255,255,255,1), rgba(255,255,255,0)); | |
| } | |
| &::after { | |
| left: 0; | |
| bottom: 0; | |
| z-index: 1; | |
| width: 100%; | |
| content: ''; | |
| height: 10px; | |
| position: absolute; | |
| background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,1)); | |
| } | |
| } | |
| ul { | |
| margin: 0; | |
| padding: 0; | |
| animation: scrollUp 1.5s .16s infinite forwards; | |
| li { | |
| opacity: 1; | |
| height: 20px; | |
| padding: 10px; | |
| list-style: none; | |
| } | |
| } | |
| @keyframes fadeOut { | |
| from { | |
| opacity: 1; | |
| } | |
| to { | |
| opacity: 0; | |
| } | |
| } | |
| @keyframes scrollUp { | |
| from { | |
| transform: translateY(0); | |
| } | |
| to { | |
| transform: translateY((-100% / $item-count) * ($item-count - 1)); | |
| } | |
| } |
Vertiaclly-scrolling list that has the appearance of fading in and out.
A Pen by Matt Soria on CodePen.