css实现文字滚动绕道效果代码

代码语言:html

所属分类:加载滚动

代码描述:css实现文字滚动绕道效果代码

代码标签: css 文字 滚动 绕道

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">

<style>
@import '//repo.bfw.wiki/bfwrepo/css/normalize.min.css' layer(normalize);

@layer base, scroll-stuff;

@layer scroll-stuff {
	@supports (animation-timeline: scroll()) {
		ul {
			gap: 0.5ch;
		}
		li {
			-webkit-animation: shift both ease-in-out;
			        animation: shift both ease-in-out;
			animation-timeline: view();
			animation-range: cover calc(50% - 12rlh) cover calc(50% + 12rlh);
		}

		li:nth-of-type(odd) {
			--shift: -4ch;
		}
		li:nth-of-type(even) {
			--shift: 4ch;
		}

		@-webkit-keyframes shift {
			50% {
				translate: var(--shift) -50%;
			}
		}

		@keyframes shift {
			50% {
				translate: var(--shift) -50%;
			}
		}

		.collab span:nth-of-type(1),
		.collab span:nth-of-type(3) {
			-webkit-animation: slide both ease-out;
			        animation: slide both ease-out;
			animation-timeline: --collab;
			animation-range: entry 100% exit 0;
		}

		@-webkit-keyframes slide {
			0% {
				translate: var(--origin-x, 0) var(--origin-y, -50%);
				opacity: 0;
			}
		}

		@keyframes slide {
			0% {
				translate: var(--origin-x, 0) var(--origin-y, -50%);
				opacity: 0;
			}
		}

		header span:nth-of-type(1) {
			--origin-x: 0;
			--origin-y: 150%;
		}
		header span:nth-of-type(3) {
			--origin-x: 0;
			--origin-y: -250%;
		}
		.collab span:nth-of-type(1) {
			--origin-x: 0;
			--origin-y: -250%;
		}
		.collab span:nth-of-type(3) {
			--origin-x: 0;
			--origin-y: 150%;
		}

		:root {
			timeline-scope: --main;
		}

		main {
			view-timeline: --main;
		}

		header span:nth-of-type(1),
		header span:nth-of-type(3) {
			animation: slide both ease-out reverse;
			animation-timeline: --main;
			animation-range: entry 0 entry 50%;
		}
	}
}

@layer base {
	*,
	*:after,
	*:before {
		box-sizing: border-box;
	}

	body {
		display: grid;
		place-items.........完整代码请登录后点击上方下载按钮下载查看

网友评论0