css动态飞飞荷包蛋

图片预览

html布局

<div class="egg">

		<div class="liu">

			<div class="l"></div>
			<div class="liu-l"></div>

			<div class="l"></div>
			<div class="liu-l"></div>

			<div class="l"></div>
			<div class="liu-l"></div>

			<div class="l"></div>

		</div>



		<div class="dan">
			<div class="huang">

				<div class="g1"></div>
				<div class="g2"></div>

				<div class="yan">
					<div class="yanj"></div>
					<div class="yanj"></div>
				</div>

				<div class="sai">
					<div class="s1"></div>
					<div class="s1"></div>
				</div>

				<div class="zui"></div>

			</div>
		</div>

	</div>

	<div class="starts">

		<span class="start"></span>
		<span class="start"></span>
		<span class="start"></span>
		<span class="start"></span>
		<span class="start"></span>
		<span class="start"></span>
		<span class="start"></span>


	</div>

css样式实现

		body {
			background-color: black;
			height: 100%;
			overflow: hidden;
		}

		.egg {
			display: flex;
			position: absolute;
			left: calc(50% - 144px);
			/* 居中.50%-这个容器宽的一半 */
			top: calc(50% - 90px);
			/* 同上,减去高的一半 */

			animation: fly 2.5s infinite;

			z-index: 9;
		}

		.dan {
			background-color: white;
			width: 200px;
			height: 180px;
			position: relative;
			/* 相对定位 */

			/* 圆角边框border-radius.值为50%,则为正圆. */

			border-top-right-radius: 100px;
			border-bottom-right-radius: 100px;

			box-shadow: 0px 0px 15px white;
		}

		.huang {
			background-color: gold;
			width: 150px;
			height: 150px;
			border-radius: 50%;

			position: absolute;
			/* 绝对定位 */
			top: 15px;
			right: 15px;

			box-shadow: inset 10px 1px #ffcc24;
			/* box-shadow向框添加一个或者多个阴影
				box-shadow: h-shadow(*水平位置) v-shadow(*垂直位置) blur(模糊距离) 
							spead(阴影尺寸) color(颜色) inset(内部阴影[outset 默认 外部阴影]); */
		}

		.g1 {
			background-color: white;
			width: 8px;
			height: 8px;
			border-radius: 50%;

			position: absolute;
			top: 10px;
			right: 38px;

		}

		.g2 {
			background-color: white;
			width: 8px;
			height: 12px;
			border-radius: 5px;

			position: absolute;
			top: 18px;
			right: 28px;

			transform: rotate(-40deg);
			/* 用于元素2·3d转化.允许将元素旋转·缩放·移动·倾斜
				rotate: 角度; 2d旋转 */

		}

		.yan {
			display: flex;
			/* 下方需要.定义为弹性盒子 */
			justify-content: space-between;
			/* justify-content 设置弹性盒子在主轴(横轴)方向上的对齐方向
				flex-  start默认,容器开头 end结尾
				center容器中心
				space-  around位于各行之间,之前,之后都留有空白的容器
						between位于各行之间留有空白的容器 */
			position: absolute;
			top: 50px;
			right: 35px;
			width: 80px;
			/* 容器宽度,设置了时候才会有空白 */

		}

		.yanj {
			background-color: black;
			width: 15px;
			height: 15px;
			border-radius: 50%;

			animation: zyan 2.5s infinite;
			/* 添加动画,并设置时间和属性 */
		}

		.sai {
			display: flex;
			/* 下方需要.定义为弹性盒子 */
			justify-content: space-between;
			width: 100px;
			position: absolute;
			top: 65px;
			right: 26px;
		}

		.s1 {
			background-color: hotpink;
			width: 15px;
			height: 10px;
			border-radius: 9px;
		}


		.zui {
			width: 15px;
			height: 15px;
			border-radius: 50%;

			position: absolute;
			top: 65px;
			right: 65px;

			border-bottom: 5px solid #000000;
			/* 设置下边框样式 border-bottom: width style color; */
		}


		.liu {
			display: flex;
			flex-direction: column;
			/* 						 */
			justify-content: space-between;
			align-items: flex-end;

			height: 180px;
			width: 100px;

			margin-right: -12px;
		}

		.l {
			background-color: #FFFFFF;
			width: 100px;
			height: 24px;

			border-top-left-radius: 25px;
			border-bottom-left-radius: 25px;

			position: relative;

		}

		.l:nth-child(1)

		/* 动画 */
			{
			animation: ldong 1s .3s infinite;
			/* 名字 时间 延迟 属性(永久) */
		}

		.l:nth-child(1)::before {
			animation: ldan 1s .6s infinite;
		}

		.l:nth-child(3) {
			animation: ldong 1s .7s infinite;
		}

		.l:nth-child(3)::before {
			animation: ldan 1s .7s infinite;
		}

		.l:nth-child(5) {
			animation: ldong 1s .1s infinite;
		}

		.l:nth-child(5)::before {
			animation: ldan 1s .1s infinite;
		}

		.l:nth-child(7) {
			animation: ldong 1s .9s infinite;
		}

		.l:nth-child(7)::before {
			animation: ldan 1s .9s infinite;
		}

		.l::before

		/* 伪类,小圆球 */
			{
			content: "";
			position: absolute;
			left: -40px;
			width: 24px;
			height: 24px;
			border-radius: 50%;
			background-color: white;
			/* animation: ldan 0.6s infinite; */
		}


		.liu-l {
			height: 29px;
			width: 30px;
			border-radius: 25px;
			background-color: black;

			z-index: 999;
			/* 层级关系 */
		}


		.start {
			width: 20px;
			height: 20px;
			border-radius: 50%;
			background: linear-gradient(to left, #48098b, #00baee);

			display: inline-block;

			position: absolute;
			top: 50px;
			left: 100%;

			animation: xing 1.5s infinite;

			z-index: 5;

		}

		.start:nth-child(2) {
			width: 30px;
			height: 2px;
			border-radius: 50%;
			background: linear-gradient(to left, #48098b, #00baee);

			display: inline-block;

			position: absolute;
			top: 100px;
			left: 100%;

			animation: xing .5s .6s infinite;

		}

		.start:nth-child(3) {
			width: 30px;
			height: 30px;
			border-radius: 50%;
			background: linear-gradient(to left, #48098b, #00baee);

			display: inline-block;

			position: absolute;
			top: 500px;
			left: 100%;

			animation: xing 1.5s .9s infinite;

		}

		.start:nth-child(4) {
			width: 10px;
			height: 10px;
			border-radius: 50%;
			background: linear-gradient(to left, #48098b, #00baee);

			display: inline-block;

			position: absolute;
			top: 200px;
			left: 100%;

			animation: xing 1s .3s infinite;

		}

		.start:nth-child(5) {
			width: 40px;
			height: 2px;
			border-radius: 50%;
			background: linear-gradient(to left, #48098b, #00baee);

			display: inline-block;

			position: absolute;
			top: 550px;
			left: 100%;

			animation: xing .5s .2s infinite;

		}

		.start:nth-child(6) {
			width: 15px;
			height: 15px;
			border-radius: 50%;
			background: linear-gradient(to left, #48098b, #00baee);

			display: inline-block;

			position: absolute;
			top: 400px;
			left: 100%;

			animation: xing .5s .4s infinite;

		}

		.start:nth-child(7) {
			width: 10px;
			height: 10px;
			border-radius: 50%;
			background: linear-gradient(to left, #48098b, #00baee);

			display: inline-block;

			position: absolute;
			top: 300px;
			left: 100%;

			animation: xing .5s .7s infinite;

		}




		/* //动画 */

		@keyframes zyan

		/* 眨眼 */
			{
			0% {
				transform: scaleY(1);
			}

			40% {
				transform: scaleY(1);
			}

			50% {
				transform: scaleY(0);
			}

			60% {
				transform: scaleY(1);
			}

			100% {
				transform: scaleY(1);
			}
		}

		@keyframes ldong {

			/* 流动 */
			0% {
				transform: translateX(0);
			}

			50% {
				transform: translateX(60px);
			}

			100% {
				transform: translateX(0px);
			}
		}

		@keyframes ldan {

			/* 颜色变淡 */
			0% {
				opacity: 0;
			}

			50% {
				opacity: 1;
			}

			100% {
				opacity: 0;
			}
		}

		@keyframes fly {

			/* 飞天荷包蛋 */
			0% {
				transform: translateX(0px);
			}

			50% {
				transform: translateX(200px);
			}

			100% {
				transform: translateX(0px);
			}
		}

		@keyframes xing {

			/* 星星 */
			0% {
				left: 100%;
			}

			100% {
				left: -200px;
			}
		}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Vue的单文件组件中,可以通过使用v-bind指令将CSS值与动态组件状态关联起来。你可以使用字符串、对象、CSS模块和自定义注入名称来实现动态CSS样式。 使用字符串方式,你可以在template中定义一个class,然后在style标签中使用v-bind绑定动态的颜色值。例如: ```html <template> <div :class="cssStyle">css-style</div> </template> <script> import { ref } from 'vue'; const colorRed = ref("red"); </script> <style lang="less" scoped> .css-style { color: v-bind(colorRed); } </style> ``` 使用对象方式,你可以在template中定义一个class,然后在style标签中使用v-bind绑定一个对象的颜色属性。例如: ```html <template> <div :class="cssStyle">css-style</div> </template> <script> import { ref } from 'vue'; const obj = ref({ color: "red" }); </script> <style lang="less" scoped> .css-style { color: v-bind('obj.color'); } </style> ``` 使用CSS模块方式,你可以在style标签中使用module属性,并将生成的CSS类作为$style对象的键暴露给组件。例如: ```html <template> <div :class="$style.red">$style.red</div> </template> <style module> .red { color: red; } </style> ``` 使用自定义注入名称,你可以在style标签的module属性中定义一个自定义的名称,然后在class中使用该名称。例如: ```html <template> <div :class="[zxx.red, zxx.border">$style.red</div> </template> <style module="zxx"> .red { color: red; } .border { border: 1px solid #000; } </style> ``` 最后,你还可以在template中使用数组形式来指定动态CSS样式。例如: ```html <div :style="[baseStyles, overridingStyles"></div> <div :style="[{color:(index == 1 ? conFontColor:'#000')},{fontSize:'18px'}"></div> ``` 以上是关于在Vue中如何使用CSS动态样式的几种方式。希望对你有所帮助!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [css Style、动态样式](https://blog.csdn.net/weixin_45137240/article/details/131042283)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [动态样式绑定--style 和 class](https://blog.csdn.net/lzfengquan/article/details/125521472)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值