Skip to content

Instantly share code, notes, and snippets.

@kobitoDevelopment
Last active April 8, 2022 07:13
Show Gist options
  • Select an option

  • Save kobitoDevelopment/774a818423ed2a8d30d29d45dba82171 to your computer and use it in GitHub Desktop.

Select an option

Save kobitoDevelopment/774a818423ed2a8d30d29d45dba82171 to your computer and use it in GitHub Desktop.
<div class="clip-wrap">
<div class="clip-top"></div>
<div class="clip-bottom"></div>
</div>
const clipWrap = document.querySelector(".clip-wrap");
clipWrap.classList.add("is-active");
$(".clip-wrap").addClass("is-active"); //デバッグ用
.clip-wrap {
position: relative;
width: 500px; //希望のコンテンツ横幅
.clip-top {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 2;
background: red; //デバッグ用カラー
transition: 0.6s;
clip-path: polygon(0 0, 0 0, 0 0);
}
.clip-bottom {
position: relative;
top: 0;
left: 0;
height: 300px; //デバッグ用高さ設定
z-index: 1;
background: blue; //デバッグ用カラー
}
&.is-active {
.clip-top {
transition: 0.6s;
clip-path: polygon(0 0, 100% 100%, 100% 0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment