<div class="p-mv">
	<div class="p-mv__title">
		<div class="p-anima-5 __anima" id="js-anima-5">
			<span>The best of both worlds</span>
		</div>
	</div>
</div>

<button type="button" data-reload="js-anima-5" id="js-reload">リロード</button>
.p-anima-5 {
  display: inline-block;
  position: relative;
}
.p-anima-5::before {
  content: "";
  display: block;
  background-color: #333;
  position: absolute;
  top: 0;
  left: 0;
  right: 100%;
  bottom: 0;
}
.p-anima-5.__anima::before {
	animation: anima_bg_5 0.9s ease-out 1 forwards;
}

.p-anima-5 span {
  position: relative;
  z-index: 1;
  opacity: 0;
}
.p-anima-5.__anima span {
	animation: anima_fadein_5 0.5s ease-out 0.7s 1 forwards;
}

@keyframes anima_fadein_5 {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
@keyframes anima_bg_5 {
  0% {
    left: 0;
    right: 100%;
  }
  40% {
    left: 0;
    right: 0;
  }
  60% {
    left: 0;
    right: 0;
  }
  100% {
    left: 100%;
    right: 0;
  }
}


/* アニメーションとは関係のないスタイル(ボタンの見た目など) */
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;
  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

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.