[點(diǎn)晴永久免費(fèi)OA]原生手寫(xiě)一鏡到底特效《龍年大吉》。
上源碼:<div class="perspective-box">
<div class="cover"></div>
<div class="perspective-content pc1">
<div class="sence-box sence-box1">
<div class="sence-in">
<div class="text-left text-box">掘金多多</div>
<div class="text-right text-box">大展鴻圖</div>
<div class="long long-left"></div>
<div class="long long-right"></div>
<div class="denglong-box"></div>
<div class="long2 long2-left"></div>
<div class="long2 long2-right"></div>
</div>
</div>
<div class="sence-box sence-box2">
<div class="sence-in">
<div class="text-left text-box">步步高升</div>
<div class="text-right text-box">年年有魚(yú)</div>
<div class="long long-left"></div>
<div class="long long-right"></div>
<div class="denglong-box"></div>
<div class="long2 long2-left"></div>
<div class="long2 long2-right"></div>
<div class="xiangyun"></div>
</div>
</div>
<div class="sence-box sence-box3">
<div class="sence-in">
<div class="text-left text-box">心想事成</div>
<div class="text-right text-box">萬(wàn)事如意</div>
<div class="long long-left"></div>
<div class="long long-right"></div>
<div class="denglong-box"></div>
<div class="long2 long2-left"></div>
<div class="long2 long2-right"></div>
<div class="xiangyun"></div>
</div>
</div>
<div class="sence-box sence-box4">
<div class="sence-in">
<div class="text-left text-box">蒸蒸日上</div>
<div class="text-right text-box">一帆風(fēng)順</div>
<div class="long long-left"></div>
<div class="long long-right"></div>
<div class="denglong-box"></div>
<div class="long2 long2-left"></div>
<div class="long2 long2-right"></div>
<div class="xiangyun"></div>
</div>
</div>
<div class="sence-box sence-box5">
<div class="sence-in">
<div class="text-left text-box">自強(qiáng)不息</div>
<div class="text-right text-box">恭喜發(fā)財(cái)</div>
<div class="sence-block">龍年大吉</div>
<div class="denglong-box"></div>
<div class="long long-left"></div>
<div class="long long-right"></div>
<div class="long2 long2-left"></div>
<div class="long2 long2-right"></div>
<div class="xiangyun"></div>
</div>
</div>
</div> <div class="perspective-content pc2">
<div class="sence-box sence-box1">
<div class="sence-in">
<div class="text-left text-box">掘金多多</div>
<div class="text-right text-box">大展鴻圖</div>
<div class="long long-left"></div>
<div class="long long-right"></div>
<div class="denglong-box"></div>
<div class="long2 long2-left"></div>
<div class="long2 long2-right"></div>
</div>
</div>
<div class="sence-box sence-box2">
<div class="sence-in">
<div class="text-left text-box">步步高升</div>
<div class="text-right text-box">年年有魚(yú)</div>
<div class="long long-left"></div>
<div class="long long-right"></div>
<div class="denglong-box"></div>
<div class="long2 long2-left"></div>
<div class="long2 long2-right"></div>
<div class="xiangyun"></div>
</div>
</div>
<div class="sence-box sence-box3">
<div class="sence-in">
<div class="text-left text-box">心想事成</div>
<div class="text-right text-box">萬(wàn)事如意</div>
<div class="long long-left"></div>
<div class="long long-right"></div>
<div class="denglong-box"></div>
<div class="long2 long2-left"></div>
<div class="long2 long2-right"></div>
<div class="xiangyun"></div>
</div>
</div>
<div class="sence-box sence-box4">
<div class="sence-in">
<div class="text-left text-box">蒸蒸日上</div>
<div class="text-right text-box">一帆風(fēng)順</div>
<div class="long long-left"></div>
<div class="long long-right"></div>
<div class="denglong-box"></div>
<div class="long2 long2-left"></div>
<div class="long2 long2-right"></div>
<div class="xiangyun"></div>
</div>
</div>
<div class="sence-box sence-box5">
<div class="sence-in">
<div class="text-left text-box">自強(qiáng)不息</div>
<div class="text-right text-box">恭喜發(fā)財(cái)</div>
<div class="sence-block">龍年大吉</div>
<div class="denglong-box"></div>
<div class="long long-left"></div>
<div class="long long-right"></div>
<div class="long2 long2-left"></div>
<div class="long2 long2-right"></div>
<div class="xiangyun"></div>
</div>
</div>
</div>
</div> @font-face {
font-family: "albb";
font-weight: 400;
src: url("http://at.alicdn.com/wf/webfont/UtqyOOTInYwh/j66d3Uavi7Io.woff2")
format("woff2"),
url("http://at.alicdn.com/wf/webfont/UtqyOOTInYwh/ElZddLrzcmO1.woff")
format("woff");
font-display: swap;
}
* {
box-sizing: border-box;
font-family: albb;
border: none!important;
}
html,
body {
display: flex;
justify-content: center;
align-items: center;
margin: 0;
padding: 0;
height: 100%;
/* background: url('https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4a8a979202e043c480960b25d385e7a5~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=798&h=998&s=33164&e=webp&b=9a010b') no-repeat center; */
/* background: url('https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/a6bdca2510534ecab6101a930f4f4d7c~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=437&h=800&s=426980&e=webp&f=125&b=c81212') no-repeat center; */
background-size: cover;
font-family: albb;
background: linear-gradient(45deg, rgb(77, 3, 3), rgb(157, 1, 1));
} .cover {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: url("https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/f515124157f748968b3dcc84a38ad067~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=364&h=575&s=1117790&e=webp&f=100&b=e6e2bd")
no-repeat;
background-size: 100%;
}
.perspective-box {
perspective: 800px;
perspective-origin: center center;
transform-style: preserve-3d;
/* border: 4px solid green; */
/* background: url("https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4a8a979202e043c480960b25d385e7a5~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=798&h=998&s=33164&e=webp&b=9a010b") */
/* no-repeat center; */
/* background: url('./bg22.jpg') no-repeat; */
background: linear-gradient(45deg, rgb(77, 3, 3), rgb(157, 1, 1));
background-size: cover;
border: 1px dashed yellow!important;
/*
position: absolute;
left: 0;
top:0;
border: 1px solid red;
*/
width: 1000px;
height: 600px;
overflow: hidden;
} .perspective-content {
/* perspective: 2000px; */
transform-style: preserve-3d;
position: absolute;
left: 0;
top: 0;
/* border: 1px solid red; */
width: 100%;
height: 100%;
/* animation: upup 5s linear infinite; */
} .pc2 {
transform: translateZ(-3000px) rotate(0deg);
} .sence-box {
position: absolute;
left: 0;
top: 0;
/* margin-left: -100vw; */
/* border: 1px solid green; */
width: 100%;
height: 100%;
transform-style: preserve-3d;
} .sence-in {
transform-style: preserve-3d;
border: 1px solid #fff;
height: 500px;
} .sence-in .text-box {
display: flex;
justify-content: center;
align-items: center;
text-align: center;
flex-direction: column;
position: absolute;
left: 0;
top: 100px;
/* border: 1px solid red; */
width: 200px;
height: 400px;
background: url("https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/31b3bc1063274e28ba90adf7cb7edce8~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=386&h=901&s=7074&e=webp&a=1&b=db2721")
no-repeat;
background-size: 100% 100%;
padding: 0 60px;
font-size: 50px;
color: #dbbb78;
} .sence-in .text-right {
left: auto;
right: 0;
} .pc1 {
animation: pc1 20s linear infinite;
}
.pc2 {
animation: pc2 20s linear infinite;
} .pc2 .sence-box img {
/* border-color: red; */
}
.sence-block {
position: absolute;
width: 200px;
height: 200px;
top: 200px;
left: 400px;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
padding: 40px;
background: url("https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/6b265e7d23f34e769ec9a5f952fee069~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=1176&h=1176&s=49626&e=webp&a=1&b=d5502f")
no-repeat;
background-size: cover;
font-size: 30px;
color: #c4af47;
} .long {
position: absolute;
left: -400px;
bottom: 0;
border: 1px solid #fff;
width: 400px;
height: 300px;
background: url('https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/9705e283dc414d6484cf1c467a859ed4~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=1200&h=570&s=115094&e=png&a=1&b=d90e00') no-repeat right bottom;
background-size: contain;
/* transform:translateZ(300px); */
} .long-right{
left: auto;
right: -400px;
transform: rotateY(180deg);
} .long2 {
position: absolute;
left: 200px;
bottom: 0;
width: 150px;
height: 150px;
border: 1px solid yellow;
background: url('https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/06b7e8f187a34109a134aa24b66f1d78~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=954&h=647&s=792959&e=png&a=1&b=e04736')no-repeat center;
background-size: contain;
transform: translateZ(600px);
} .long2-right {
left: auto;
right: 200px;
} .xiangyun{
position: absolute;
left: -400px;
bottom: 0;
width: 1600px;
height: 600px;
background: url('https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/aa5a2687d1244108afefd86b4ef5729a~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=1157&h=369&s=62644&e=png&a=1&b=d60101') no-repeat center;
background-size: contain;
border: 1px solid yellow;
transform: translateZ(-200px);
} .hua {
position: absolute;
left: 120px;
top: 130px;
height: 50px;
border: 1px solid #fff;
width: 50px;
background: url('./hua.png') no-repeat center;
background-size: contain;
/* animation: rot 5s infinite linear; */
} .sence-box1 {
transform: translateZ(-500px);
} .sence-box2 {
transform: translateZ(-1500px);
} .sence-box3 {
transform: translateZ(-2500px);
}
.sence-box4 {
transform: translateZ(-3500px);
}
.sence-box5 {
transform: translateZ(-4500px);
} .denglong-box {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 300px;
background: url("https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/f4b556643a2e48289af3dad79ad29033~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=802&h=1373&s=57508&e=webp&a=1&b=d6502f")
no-repeat 50px,
url("https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/c2a79cfefa0d43d8b550f3675753b94c~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=809&h=1528&s=43006&e=webp&a=1&b=d14a30")
no-repeat 150px,
url("https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/f4b556643a2e48289af3dad79ad29033~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=802&h=1373&s=57508&e=webp&a=1&b=d6502f")
no-repeat 800px,
url("https://p1-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/c2a79cfefa0d43d8b550f3675753b94c~tplv-k3u1fbpfcp-jj-mark:0:0:0:0:q75.image#?w=809&h=1528&s=43006&e=webp&a=1&b=d14a30")
no-repeat 720px;
background-size: 120px, 100px;
transform: translateZ(400px);
} @keyframes pc1 {
0% {
transform: translateZ(0px);
z-index: 99;
} 50% {
transform: translateZ(6000px);
z-index: 99;
}
50.1% {
transform: translateZ(-6000px);
/* opacity: 0.5; */
z-index: 1;
}
60% {
/* opacity: 1; */
}
100% {
transform: translateZ(0px);
z-index: 1;
}
}
@keyframes pc2 {
0% {
transform: translateZ(-6000px);
z-index: 1;
/* opacity: 0.5; */
}
10% {
/* opacity: 1; */
}
50% {
z-index: 1;
}
50.1% {
z-index: 99;
}
100% {
transform: translateZ(6000px);
z-index: 99;
}
} @keyframes rot {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
} 整體實(shí)現(xiàn)思路介紹
1、一鏡到底特效 的整體布局、設(shè)計(jì)、及動(dòng)畫(huà)思路如下圖所示,一鏡到底的案例特效 最核心的就是要 構(gòu)成一套 在3D 空間中, 有多個(gè)平行的場(chǎng)景, 然后以攝像機(jī)的視角 從前往后 移動(dòng),在場(chǎng)景中穿梭, 依次穿過(guò)每一個(gè)場(chǎng)景的頁(yè)面即可,自己閉上眼睛來(lái)體會(huì)一下吧。 對(duì)應(yīng)到本案例中效果就是這樣啦: 當(dāng)然有朋友會(huì)說(shuō)看上圖,感覺(jué)不到明顯的3D 立體效果, 那再來(lái)看看下面這個(gè)圖吧; 上面這張圖就是 基于人眼 看不同距離的物體呈現(xiàn)出的結(jié)果, 也就是透視效果, 透視效果最核心的特點(diǎn)就是近大遠(yuǎn)?。欢绊懣吹酵敢曃矬w大小的一個(gè)參數(shù)就是消失點(diǎn)距離, 比如消失點(diǎn)越近,最遠(yuǎn)處的物體會(huì)越小, 近大遠(yuǎn)小的效果越明顯, 自己閉上眼睛來(lái)體會(huì)一下吧。 對(duì)應(yīng)到本案例中效果就是這樣啦: 注意:本案例中 的主要功能是動(dòng)效, 所以在頁(yè)面框架布局上,大多使用的都是定位布局, 布局中的基礎(chǔ)概念 ‘子絕父相’ 就不用我多說(shuō)了吧 上述框架對(duì)應(yīng)的HTML源碼如下, 其中.sence-in 內(nèi)部的子元素是素材,可以先忽略: <div class="sence-box sence-box1"> <div class="sence-in"> <div class="text-left text-box">掘金多多</div> <div class="text-right text-box">大展鴻圖</div> <div class="long long-left"></div> <div class="long long-right"></div> <div class="denglong-box"></div> <div class="long2 long2-left"></div> <div class="long2 long2-right"></div> </div> </div> <div class="sence-box sence-box2"> <div class="sence-in"> <div class="text-left text-box">步步高升</div> <div class="text-right text-box">年年有魚(yú)</div> <div class="long long-left"></div> <div class="long long-right"></div> <div class="denglong-box"></div> <div class="long2 long2-left"></div> <div class="long2 long2-right"></div> <div class="xiangyun"></div> </div> </div> <div class="sence-box sence-box3"> <div class="sence-in"> <div class="text-left text-box">心想事成</div> <div class="text-right text-box">萬(wàn)事如意</div> <div class="long long-left"></div> <div class="long long-right"></div> <div class="denglong-box"></div> <div class="long2 long2-left"></div> <div class="long2 long2-right"></div> <div class="xiangyun"></div> </div> </div> <div class="sence-box sence-box4"> <div class="sence-in"> <div class="text-left text-box">蒸蒸日上</div> <div class="text-right text-box">一帆風(fēng)順</div> <div class="long long-left"></div> <div class="long long-right"></div> <div class="denglong-box"></div> <div class="long2 long2-left"></div> <div class="long2 long2-right"></div> <div class="xiangyun"></div> </div> </div> <div class="sence-box sence-box5"> <div class="sence-in"> <div class="text-left text-box">自強(qiáng)不息</div> <div class="text-right text-box">恭喜發(fā)財(cái)</div> <div class="sence-block">龍年大吉</div> <div class="denglong-box"></div> <div class="long long-left"></div> <div class="long long-right"></div> <div class="long2 long2-left"></div> <div class="long2 long2-right"></div> <div class="xiangyun"></div> </div> </div> 知識(shí)點(diǎn)一: CSS3中的坐標(biāo)系CSS3中的坐標(biāo)系,是一切3D 效果的基石, 務(wù)必熟練掌握 , 如下圖所示:
知識(shí)點(diǎn)二: 透視(perspective)
在CSS中,我們可以通過(guò)在父元素上設(shè)置 .container { perspective: 1000px; } 在這個(gè)例子中,我們?yōu)?code>.container元素設(shè)置了 知識(shí)點(diǎn)三:3D 變換的核心屬性: transform-style
例如: /* 透視屬性加給了 最外層的元素, 保證所有子元素的透視效果是一致的,協(xié)調(diào)的*/ .perspective-box { transform-style: preserve-3d; } 在這個(gè)例子中,我們?yōu)?code>.perspective-box元素設(shè)置了
知識(shí)點(diǎn)四、perspective和transform-style的差異和注意點(diǎn)(炒雞重要!)
注意:perspective屬性,只能帶來(lái)近大遠(yuǎn)小的透視視覺(jué)效果,并不能構(gòu)成真正的3D空間布局。真正的3D布局必須依賴于 知識(shí)點(diǎn)五、animation動(dòng)畫(huà)的定義和使用CSS動(dòng)畫(huà)是一種使元素從一種樣式逐漸改變?yōu)榱硪环N樣式的方法。這個(gè)過(guò)程是通過(guò)關(guān)鍵幀(keyframes)來(lái)定義的,關(guān)鍵幀定義了動(dòng)畫(huà)過(guò)程中的不同狀態(tài)。 在一鏡到底的案例中, 整個(gè)場(chǎng)景的前后移動(dòng),用的就是動(dòng)畫(huà)屬性。 動(dòng)畫(huà)的使用分為兩步, 具體使用方式如下:
@keyframes rotate { from { transform: rotateX(0deg); } to { transform: rotateX(360deg); } } 在這個(gè)例子中,我們定義了一個(gè)名為“rotate”的關(guān)鍵幀動(dòng)畫(huà),使元素從X軸的0度旋轉(zhuǎn)到360度。然后,我們可以通過(guò)將這個(gè)動(dòng)畫(huà)應(yīng)用到HTML元素上來(lái)使用它: .perspective-content { animation: rotate 5s infinite linear; } 在這個(gè)例子中,我們將“rotate”動(dòng)畫(huà)應(yīng)用到 在一鏡到底的案例中, 我們定義的動(dòng)畫(huà)如下: @keyframes perspective-content {
0% { transform: translateZ(0px); } 50% { transform: translateZ(6000px); }
50.1% { transform: translateZ(-6000px); }
100% { transform: translateZ(0px); } } 上午動(dòng)畫(huà) 其實(shí)做了一個(gè)無(wú)線循環(huán)輪播的邏輯, 就是當(dāng) 在Z軸方向上 從 0 移動(dòng)到 6000距離以后, 在重置到-6000px, 這樣就可以在從-6000繼續(xù)向前移動(dòng), 移動(dòng)到 0 ,達(dá)到一個(gè)循環(huán), 再開(kāi)始下一次的循環(huán);
該文章在 2024/1/27 17:39:58 編輯過(guò) |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |