CSS学习——动画(5)

博客汇总了项目中使用的动画,主要包括旋转木马和下拉列表这两种动画类型,与信息技术中的前端动画展示相关。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目中使用的动画汇总

1、旋转木马

<!DOCTYPE html>
<html>
	<head>
		<style>
			.stage {
				perspective: 1200px;
			}

			.box {

				position: relative;
				height: 300px;
				width: 300px;
				margin: 200px auto;
				transform-style: preserve-3d;				
				animation: rotate 8s infinite linear;

			}

			.item {
				position: absolute;
				top: 0;
				left: 0;
				height: 100%;
				width: 100%;
				line-height: 300px;
				text-align: center;
				font-size: 100px;
				border: 1px solid red;

			}

			.item-1 {
				transform: translateZ(260px);
				background-color: rgba(255, 0, 0, .5);
			}

			.item-2 {
				transform: rotateY(60deg) translateZ(260px);
				background-color: rgba(0, 255, 0, .5);
			}

			.item-3 {
				transform: rotateY(120deg) translateZ(260px);
				background-color: rgba(0, 0, 255, .5);
			}


			.item-4 {
				transform:  rotateY(180deg) translateZ(260px);
				background-color: rgba(255, 255, 0, .5);
			}

			.item-5 {
				transform: rotateY(240deg) translateZ(260px);
				background-color: rgba(255, 0, 255, .5);
			}

			.item-6 {
				transform: rotateY(300deg) translateZ(260px);
				background-color: rgba(0, 255, 255, .5);
			}
			.item-a {
				transform:  translateZ(150px)  translateY(-100px);
				background-color: rgba(0, 255, 255, .5);
			}
			.item-b {
				transform: rotateY(90deg) translateZ(150px) translateY(-100px);
				background-color: rgba(0, 255, 255, .5);
			}
			.item-c {
				transform: rotateY(180deg) translateZ(150px) translateY(-100px);
				background-color: rgba(0, 255, 255, .5);
			}
			.item-d {
				transform: rotateY(270deg) translateZ(150px) translateY(-100px);
				background-color: rgba(0, 255, 255, .5) translateY(-100px);
			}

			@keyframes rotate {
				from {
					transform: rotateY(360deg);
				}

				to {
					transform: rotateY(0deg);
				}
			}
		</style>
	</head>

	<body>
		<div class="stage">
			<div class="box">
				<div class="item item-1">1</div>
				<div class="item item-2">2</div>
				<div class="item item-3">3</div>
				<div class="item item-4">4</div>
				<div class="item item-5">5</div>
				<div class="item item-6">6</div>
				<div class="item item-a">A</div>
				<div class="item item-b">B</div>
				<div class="item item-c">C</div>
				<div class="item item-d">D</div>
			</div>
		</div>
		<div class="tetst">123</div>
	</body>
</html>

2、下拉列表

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<style>
		* {
			list-style: none;
			padding: 0;
			margin: 0;

		}

		@keyframes show2 {
			from {
				height: 0px;
			}

			to {
				height: 200px;
			}
		}

		.box {
			margin-top: 10px;
			position: relative;
			width: 120px;
			padding-right: 20px;
			background-color: pink;

		}

		.box:hover ul {
			height: 200px;
			animation: show2 .5s forwards;
			/* transition: height 2s ; */
		}
		.box:hover::after{
			top: 15px;
			transform: rotate(225deg);
			transition: transform .5s ;
		}
		.box::after{
			position: absolute;
			right: 10px;
			top: 20px;
			content:"" ;
			display: block;
			width: 0;
			height: 0;
			transform: rotate(45deg);
			border-bottom: 10px solid transparent;
			border-left: 10px solid green;
		
		}

		ul::-webkit-scrollbar {
			width: 0;
		}

		p {
			height: 40px;
			line-height: 40px;
			text-align: center;
			
		}

		ul {
			position: absolute;
			top: 100%;
			left: 0;
			width: 100%;
			height: 0;
			background-color: red;
			z-index: 10;
			max-height: 200px;
			overflow-y: auto;
		}

		li {
			height: 30px;
			width: 100%;
			line-height: 30px;
			text-align: center;
			background-color: grey;
			color: #fff;
		}

		li:hover {
			background-color: green;
			color: #fff;
		}
	</style>


	<body>
		<div class="box">
			<p>请选择</p>
			<ul>
				<li>西游记1</li>
				<li>红楼梦</li>
				<li>三国演义</li>
				<li>水浒传</li>
				<li>西游记1</li>
				<li>红楼梦</li>
				<li>三国演义</li>
				<li>水浒传</li>
			</ul>
		</div>
		<div class="box">
			<p>请选择你的书</p>
			<ul>
				<li>西游记1</li>
				<li>红楼梦</li>
				<li>三国演义</li>
				<li>水浒传</li>
			</ul>
		</div>

	</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值