課程
/前端開發(fā)
/HTML/CSS
/帶你走入前端動畫的世界
為什么我和老師寫的一樣,運行出來什么也么沒有,
2019-11-26
源自:帶你走入前端動畫的世界 4-1
正在回答
<!DOCTYPE?html> <html?lang="en"> <head> ??<meta?charset="UTF-8"> ??<title>rain?animation</title> ??<style> ??body,?html?{ ??margin:?0; ??padding:?0; } body?{ ??perspective:?700px; ??background:?linear-gradient(#3d748f,?#b8d3e0); ??height:?100vh; } .rain-box?{ ??position:?relative; } .rain-box?.raindrop?{ ??position:?absolute; ??background-clip:?content-box; ??box-sizing:?border-box; ??width:?30px; ??height:?40px; ??color:?#3d588f; ??border-top:?solid?0; ??border-bottom:?solid?40px; ??border-left:?solid?15px?transparent; ??border-right:?solid?15px?transparent; ??border-radius:?50%; ??animation:?raindrop?2s?infinite?ease-in-out; ??opacity:?0; ??transform:?scale(0.5); } @keyframes?raindrop?{ ??10%?{ ????opacity:?1; ??} ??90%?{ ????transform:?scale(1.5)?translate3d(0,?calc(100vh?-?1000%),?10px)?rotateX(30deg); ??} } /*#?sourceMappingURL=css-rain.css.map?*/ ??</style> </head> <body> <div?class="rain-box"> ??<!--雨滴--> ??<!--<div?class="raindrop"></div>--> </div> <script> ??const?rainCount?=?200, ????rainFragment?=?document.createDocumentFragment(), ????clientWidth?=?document.documentElement.clientWidth, ????clientHeight?=?document.documentElement.clientHeight; ??for?(let?i?=?0;?i?<?rainCount;?i++)?{ ????let?rainEle?=?document.createElement('div'); ????rainEle.className?=?'raindrop'; ????rainEle.style.left?=?~~(Math.random()?*?(clientWidth?-?40))?+?'px'; ????rainEle.style.animationDelay?=?(Math.random()?*?rainCount?/?2).toFixed(2)?+?'s'; ????rainFragment.appendChild(rainEle) ??} ??document.querySelector('.rain-box').appendChild(rainFragment) </script> </body> </html>
<template>
<view class="content" ref="content">
<view?
class="water"
v-for="item of count"
:key="item.id"
:class="getClass()"
:style="getStyle()"
>
</view>
</template>
<script>
export default{
name:"rain",
props: {
count: {
type: Number,
default: 30
},
data(){
return{
}
methods:{
getClass() {
return `hbsd-${Math.floor(Math.random() * 50 + 30)}`;
getStyle() {
return `left:${Math.random() * 100}%;top:${Math.random() * 30}px`;
</script>
<style scoped>
.content
position relative
height 100%
background-color #f2f2f2
.water
position absolute
width 16rpx
height 24rpx
background #ccc
clip-path ellipse(20% 60% at 50% 50%)
// animation drops 2s cubic-bezier(0.82, -0.01, 0.81, 0.92) infinite
for $i in 1...100
.hbsd-{$i}
animation drops ($i/20)s cubic-bezier(0.82, -0.01, 0.81, 0.92) infinite
@keyframes drops
0%{
opacity 0
20%{
opacity 1
90%{
100%{
transform translate3d(10px,100vh,-10px)
</style>
因為老師的scss
舉報
學(xué)習(xí)css3動畫,并結(jié)合實際項目向大家展示應(yīng)用技巧,使大家快速入門。
3 回答編寫落雨代碼,為什么會出現(xiàn)$未定義,下面是我的js代碼和錯誤
2 回答紅包雨那 給 yudi css加"left"后邊那個斜引號怎么打出來的
1 回答為什么雨滴橫走
1 回答老師,視頻的代碼沒有提供嗎
4 回答啥情況,照著代碼敲,畫面顯示不出來
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2019-12-21
2019-12-03
<template>
<view class="content" ref="content">
<view?
class="water"
v-for="item of count"
:key="item.id"
:class="getClass()"
:style="getStyle()"
>
</view>
</view>
</template>
<script>
export default{
name:"rain",
props: {
count: {
type: Number,
default: 30
},
},
data(){
return{
}
},
methods:{
getClass() {
return `hbsd-${Math.floor(Math.random() * 50 + 30)}`;
},
getStyle() {
return `left:${Math.random() * 100}%;top:${Math.random() * 30}px`;
}
}
}
</script>
<style scoped>
.content
position relative
height 100%
background-color #f2f2f2
.water
position absolute
width 16rpx
height 24rpx
background #ccc
clip-path ellipse(20% 60% at 50% 50%)
// animation drops 2s cubic-bezier(0.82, -0.01, 0.81, 0.92) infinite
for $i in 1...100
.hbsd-{$i}
animation drops ($i/20)s cubic-bezier(0.82, -0.01, 0.81, 0.92) infinite
@keyframes drops
0%{
opacity 0
}
20%{
opacity 1
}
90%{
opacity 1
}
100%{
opacity 0
transform translate3d(10px,100vh,-10px)
}
</style>
2019-11-26
因為老師的scss