Показать сообщение отдельно
  #6 (permalink)  
Старый 14.05.2019, 20:32
Аватар для Malleys
Профессор
Отправить личное сообщение для Malleys Посмотреть профиль Найти все сообщения от Malleys
 
Регистрация: 20.12.2009
Сообщений: 1,714

<style>
body {
	margin: 0;
}

header {
	height: 200vh;
	background: black;
	position: relative;
}
	
header::before, header > * {
	position: sticky;
	top: 0;
	bottom: 0;
	height: 50%;
	width: 100%;
}
	
header::before {
	content: "";
	background: url("https://i.ytimg.com/vi/zf-GMvFd154/maxresdefault.jpg") no-repeat center center / cover;
	display: block;
}
	
header > section {
	display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	color: white;
	text-shadow: 0 0 2px black;
	font-family: system-ui;
	overflow: hidden;
}

header > section > video {
	position: absolute;
	width: 100%;
	height: 100%;
	z-index: -1;
	object-fit: cover;
}

</style>

<header>
	<section>
		<video src="https://www.w3schools.com/html/mov_bbb.mp4" loop muted autoplay></video>
		<section>
			<h1>Hello!</h1>
		</section>
	</section>
</header>
<div>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Est alias ipsam voluptatem impedit explicabo, dicta illo ipsa vitae odio harum eum tempore doloremque omnis doloribus repudiandae, suscipit saepe unde expedita.</p>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Est alias ipsam voluptatem impedit explicabo, dicta illo ipsa vitae odio harum eum tempore doloremque omnis doloribus repudiandae, suscipit saepe unde expedita.</p>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Est alias ipsam voluptatem impedit explicabo, dicta illo ipsa vitae odio harum eum tempore doloremque omnis doloribus repudiandae, suscipit saepe unde expedita.</p>
	<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Est alias ipsam voluptatem impedit explicabo, dicta illo ipsa vitae odio harum eum tempore doloremque omnis doloribus repudiandae, suscipit saepe unde expedita.</p>
</div>

<script>
	var video = document.querySelector("header > section > video");
	
	function opacityHandler(event) {
		video.style.opacity = Math.min(1, 4 * document.body.scrollTop/document.body.clientHeight);
	}
	
	addEventListener("scroll", opacityHandler);
	opacityHandler();

</script>

Последний раз редактировалось Malleys, 14.05.2019 в 20:44.
Ответить с цитированием