阅读 915

中秋节,我要和“对象“坐在屋顶上赏月,读诗

我正在参加中秋创意投稿大赛,详情请看juejin.cn/post/700315…

前言

马上就是中秋节啦,你们有什么安排吗?

说到中秋节,当然是和喜欢的人一起赏月祭月放孔明灯啦。

说到月亮,那我们能不能用css画个月亮,孔明灯呢,立马行动。

准备

第一步:

又大又圆的月亮

中秋节怎么能少了月亮,首先要画个月亮。

image.png

<div class="sky" id="sky">
    <div class="moon">
        <div class="moon-shadow" id="moonShadow"></div>
        <svg width="0" height="0">
            <filter id="filter">
                <feTurbulence type="fractalNoise" baseFrequency="0.034" numOctaves="4" seed="0" />
                <feDisplacementMap in="SourceGraphic" scale="150" />
            </filter>
        </svg>
    </div>
</div>
复制代码
.moon {
	position: absolute;
	border-radius: 100%;
	width: 15vw;
	height: 15vw;
	background: radial-gradient(#fffee8, #fdfe8e, #faf193);
	box-shadow: 0 0 40px 20px #fff;
	left: 1vw;
	top: 1vw;
}

.moon-shadow {
	width: 4vw;
	height: 7vw;
	border-radius: 100%;
	position: absolute;
	top: 1vw;
	left: 4.7vw;
	background: linear-gradient(51deg, #f8de2b, #f5d633, #fdf956, #feff7f, #fefec6);
}

复制代码

第二步:

孔明灯

中秋怎么能少了孔明灯呢。我们再来画个孔明灯。

image.png

<div class="kongming-latern">
    <div class="latern-left"></div>
    <div class="latern-right"></div>
    <div class="latern-bottom"></div>
</div>
复制代码
.kongming-latern,
.kongming-latern-litle {
	position: absolute;
	height: 5.1vw;
	width: 3.5vw;
	bottom: -8vw;
	background: linear-gradient(#92090e, #ea3d2d, #fbf885);
	animation: FlyOne 22s linear infinite;
}


.latern-left {
	border-left: 5vw solid transparent;
	border-right: 1vw solid transparent;
	border-bottom: 0.9vw solid #ea4c35;
	transform: rotate(-90deg);
	position: relative;
	top: 2.5vw;
	left: -3.4vw;
}

.latern-right {
	border-left: 1vw solid transparent;
	border-right: 5vw solid transparent;
	border-bottom: 0.9vw solid #ea4c35;
	transform: rotate(90deg);
	position: relative;
	top: 1.6vw;
	left: 0.9vw;
}

.latern-bottom {
	position: relative;
	top: 3vw;
	width: 3.5vw;
	height: 1.2vw;
	background: radial-gradient(#fff, #fbf885, #ea3d2d);
	border-radius: 2vw;
}
复制代码

第三步:

星星

image.png

let star = document.createElement('div');
    star.className = 'star';
    star.style = 'left: ' +
    numberRandom(150, 0) +
    'vw; top: ' +
    numberRandom(45, 0) +
    'vh; animation-delay: ' +
    numberRandom(60, 0) +
    's; animation: Wink ' +
    numberRandom(60, 0) +
    's linear infinite;';	
document.getElementById('sky').appendChild(star);
复制代码

第四步

作诗

image.png

<div id="" class="word">
	<h1 id="">
		但愿人长久,千里共婵娟。
	</h1>
</div>
复制代码

.word {
    width: 100%;
    height: 100%;
    position: relative;
    padding: 2em;
    filter: contrast(20);

}

h1 {
    font-family: Righteous;
    color: white;
    font-size: 45px;
    text-transform: uppercase;
    line-height: 1;
    animation: letterspacing 5s infinite alternate ease-in-out;
    display: block;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate3d(-50%, -50%, 0);
    letter-spacing: 2.0rem;
}

@keyframes letterspacing {
    0% {
        letter-spacing: -2.2rem;
        filter: blur(.3rem);
    }

    50% {
        filter: blur(.5rem);
    }

    100% {
        letter-spacing: .5rem;
        filter: blur(0rem);
        color: #fff;
    }
}

复制代码

第五步

屋顶

<div class="top-roof" id="topRoof">
    <div class="tile"></div>
    <div class="edge"></div>
    <div class="roof-body"></div>
</div>

复制代码
 .top-roof {
	position: absolute;
	bottom: 6vw;
	right: 0;
	border-left: 10vw solid transparent;
	border-right: 0vw solid transparent;
	border-bottom: 4vw solid #2b2a49;
}

.top-roof:before {
	content: '';
	border-bottom: 0.7vw solid #2b2a49;
	width: 11vw;
	height: 5vw;
	position: absolute;
	border-bottom-left-radius: 50%;
	border-top-left-radius: 50%;
	transform: rotate(-23deg) translate(0.7vw, -3vw);
	right: -0.2vw;
}

.top-roof:after {
	content: '';
	width: 10vw;
	height: 2vw;
	background: linear-gradient(#23314e, #657297, transparent);
	position: absolute;
	right: 0;
	top: 4vw;
	border-bottom-left-radius: 3vw;
}
复制代码

好了 那我们一幅画的主题就画好了

接下来我们稍加一点动画

月亮 - Google Chrome 2021-09-05 21-20-22.gif

@keyframes FlyOne {
	10% {
		transform: translateX(7vw) translateY(-10vh) rotate(0deg);
	}

	40% {
		transform: translateX(2vw) translateY(-30vh) rotate(5deg);
	}

	70% {
		transform: translateX(10vw) translateY(-70vh) rotate(-5deg);
	}

	100% {
		transform: translateX(3vw) translateY(-120vh) rotate(3deg);
	}
}

@keyframes FlyTwo {
	10% {
		transform: translateX(2vw) translateY(-15vh) rotate(0deg);
	}

	40% {
		transform: translateX(10vw) translateY(-60vh) rotate(5deg);
	}

	70% {
		transform: translateX(3vw) translateY(-90vh) rotate(-5deg);
	}

	100% {
		transform: translateX(12vw) translateY(-100vh) rotate(3deg);
		opacity: 0.1;
	}
}

@keyframes FlyThree {
	10% {
		transform: translateX(5vw) translateY(-20vh) rotate(0deg);
		opacity: 1;
	}

	40% {
		transform: translateX(1vw) translateY(-50vh) rotate(5deg);
		opacity: 0.8;
	}

	70% {
		transform: translateX(7vw) translateY(-80vh) rotate(-5deg);
		opacity: 0.7;
	}

	100% {
		transform: translateX(14vw) translateY(-100vh) rotate(3deg);
		opacity: 0.1;
	}
}

@keyframes FlyFour {
	100% {
		transform: translateY(-100vh);
		opacity: 0.1;
	}
}

@keyframes Wink {
	100% {
		width: 0;
	}
}

复制代码

我还没对象呢?

对象呢????????????? 山人自有妙计

最后我再new个对象房子到屋顶上。这样中秋节就能和对象坐在屋顶上赏月啦,是不是很傻叉,哈哈哈哈哈哈哈哈哈哈哈哈哈!!!

<div class="object-content">
	<div>
            const boy = new Object({ name: "zz" })
	</div>
	<div>
            const gril = new Object({ name: "zz的对象" });
	</div>
</div>

复制代码

image.png

项目地址:

项目访问地址:zhy-z.github.io/Moon/

最后

我是zz,祝各位爱情甜蜜生活美满 夜夜欢欢!!!

文章分类
前端
文章标签