【CSS】脱jQueryでCSSでライン(直線)を走らせるアニメーションの実装方法のデモページ

※デベロッパーツール等でソースコードをご確認ください(Please check using Developer tools)

スポンサーリンク

Web制作会社LIGが運営するWebデザインスクール

CSS

.wrap {
  width: 768px;
  margin: 0 auto;
}

.box02,
.box01 {
  position: relative;
  width: 100%;
  height: 300px;
  margin: 0 auto;
  background: #000;
  z-index: 1;
}

.box-wrap {
  position: relative;
  width: 100%;
  margin: 250px auto 0;
}

.line {
  position: absolute;
  top: -300px;
  left: 50%;
  margin: 0 auto;
  width: 1px;
  height: 600px;
  background-color: #444;
}

.line:after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 300%;
  height: 100%;
  background-color: #fff;
  transition: height 1s ease 1s;
}

.add.line:after {
  height: 0;
}

@media screen and (max-width:640px){
  .wrap {
    width: 100%;
  }
}
  

JavaScript

window.onload = function() {
  document.getElementById("line").classList.add("add")
};