Staircase and Sliding Text on Hover

In this tutorial, you will learn to create a staircase with sliding text on hover using CSS. The transform skew and scale properties are used to create a 3D stair step while the transform translate is used for sliding the text. Watch the video below for a detailed tutorial.


HTML

<body>
    <div class="stair">
      <div class="step">
        <p></p>
        <p>Lorem Impsum</p>
      </div>
      <div class="step">
        <p>Lorem Impsum</p>
        <p>Dolor sit</p>
      </div>
      <div class="step">
        <p>Dolor sit</p>
        <p>Consectetur</p>
      </div>
      <div class="step">
        <p>Consectetur</p>
        <p>Adipiscing</p>
      </div>
      <div class="step">
        <p>Adipiscing</p>
        <p>Do eiusmod</p>
      </div>
      <div class="step">
        <p>Do eiusmod</p>
        <p></p>
      </div>
    </div>
</body>

CSS

body {
  font-family: 'Roboto', sans-serif;
  background-color: #2e3537;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}
.stair {
  color: #4173ab;
  text-transform: uppercase;
  font-weight: bold;
  font-size: 50px;
}
.step {
  height: 40px;
  width: 400px;
  overflow: hidden;
  position: relative;
  background-color: white;
}
.step p {
  height: 43px;
  line-height: 43px;
  margin: 0;
  transition: all 1s ease-in-out;
}
.step:nth-child(odd) {
  transform: skew(60deg, -30deg) scaleY(0.667);
}
.step:nth-child(even) {
  transform: skew(0deg, -30deg) scaleY(1.333);
}
.step:nth-child(2) {
  left: 24px;
}
.step:nth-child(3) {
  left: 49px;
}
.step:nth-child(4) {
  left: 73px;
}
.step:nth-child(5) {
  left: 98px;
}
.step:nth-child(6) {
  left: 123px;
}
.stair:hover .step p {
  transform: translate(0, -43px);
}