<div class="p-mv p-anima-9 __anima" id="js-anima-9">
<div class="p-anima-9__intro">
<h2 class="p-mv__title"><span>Monkey business</span></h2>
</div>
<h2 class="p-mv__title">The best of <br>both worlds</h2>
</div>
<button type="button" data-reload="js-anima-9" id="js-reload">リロード</button>
.p-anima-9 {
position: relative;
overflow: hidden;
}
.p-anima-9__intro {
display: flex;
justify-content: center;
align-items: center;
background-color: #333;
position: absolute;
top: 0;
left: 0;
z-index: 99;
width: 100%;
height: 100%;
}
.p-anima-9.__anima .p-anima-9__intro {
animation: anima_intro_9 0.7s cubic-bezier(0.46, 0.26, 0.15, 0.89) 1.6s 1 forwards;
}
.p-anima-9__intro h2 {
overflow: hidden;
}
.p-anima-9__intro h2::before {
content: "";
display: block;
background-color: #333;
position: absolute;
bottom: -100%;
left: 0;
z-index: 1;
width: 100%;
height: 1.5em;
}
.p-anima-9.__anima .p-anima-9__intro h2::before {
animation: anima_title_musk_9 0.5s cubic-bezier(0.46, 0.26, 0.15, 0.89) 0.6s 1 forwards;
}
.p-anima-9__intro h2 span {
display: block;
transform: translate(0, 105%);
}
.p-anima-9.__anima .p-anima-9__intro h2 span {
animation: anima_title_9 0.5s cubic-bezier(0.46, 0.26, 0.15, 0.89) 1 forwards;
}
@keyframes anima_title_9 {
0% {
transform: translate(0, 105%);
}
100% {
transform: translate(0, 0);
}
}
@keyframes anima_title_musk_9 {
0% {
bottom: -100%;
}
100% {
bottom: 0;
}
}
@keyframes anima_intro_9 {
0% {
left: 0;
}
100% {
left: 100%;
}
}
/* アニメーションとは関係のないスタイル(ボタンの見た目など) */
body {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
height: 100vh;
}
button {
margin-top: 40px;
}
.p-mv {
display: flex;
align-items: center;
background-image: url("https://picsum.photos/900/600");
background-repeat: no-repeat;
background-position: 50% 50%;
background-size: cover;
padding: 40px;
width: 60%;
max-width: 500px;
height: 200px;
position: relative;
}
.p-mv::before {
content: "";
display: block;
background-color: rgba(51, 51, 51, 0.5);
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.p-mv__title {
color: #fff;
font-size: 56px;
font-weight: bold;
line-height: 1.3;
position: relative;
z-index: 1;
}
@media screen and (max-width: 640px) {
.p-mv__title {
font-size: 24px;
}
}
document.querySelector('#js-reload').addEventListener('click', (_ev) => {
const target = _ev.target.getAttribute('data-reload');
document.querySelector(`#${target}`).classList.remove('__anima');
setTimeout(() => {
document.querySelector(`#${target}`).classList.add('__anima');
}, 500);
});
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.