国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > CSS > 正文

純CSS實(shí)現(xiàn)菜單、導(dǎo)航欄的3D翻轉(zhuǎn)動(dòng)畫效果

2024-07-11 08:31:07
字體:
供稿:網(wǎng)友

我曾經(jīng)向大家展示過閃光的logo,燃燒的火狐貍,多重嵌套動(dòng)畫等例子,今天,我們將要制作一個(gè)簡(jiǎn)單但非??岬?D翻轉(zhuǎn)菜單。大家可以先看看實(shí)際效果,下面有效果截圖。

效果圖:


HTML代碼

HTML內(nèi)容是一些用作菜單的鏈接,我們?cè)诶锩嫣砑恿艘恍╊~外的SPAN標(biāo)記來幫助實(shí)現(xiàn)3D效果:

復(fù)制代碼
代碼如下:
<ul class="block-menu lazy ">
<li><a href="/" class="three-d lazy ">
Home
<span aria-hidden="true" class="three-d-box lazy ">
<span class="front lazy ">Home</span>
<span class="back lazy ">Home</span>
</span>
</a></li>
<li><a href="/demos" class="three-d lazy ">
Demos
<span aria-hidden="true" class="three-d-box lazy ">
<span class="front lazy ">Demos</span>
<span class="back lazy ">Demos</span>
</span>
</a></li>
<!-- more items here -->
</ul>

在A鏈接標(biāo)記旁邊是一系列的SPAN元素,動(dòng)畫演示過程中,它將用來表現(xiàn)3D立方體的“正面”和“背面”。這些SPAN里的文字和A鏈接里的文字是一致的。

CSS代碼

這個(gè)動(dòng)畫的過程就是實(shí)現(xiàn)3D變換和元素位置變化。但實(shí)際上A鏈接是沒有移動(dòng)的,動(dòng)的是SPAN標(biāo)簽,而且是最外層的SPAN標(biāo)簽,內(nèi)部的SPAN標(biāo)簽被初始化在它的位置上,以后就不做任何變動(dòng)。每個(gè)元素都可以向上翻,并要翻回來,我們使用的是CSS transforms。

復(fù)制代碼
代碼如下:
/* basic menu styles */
.block-menu {
display: block;
background: #000;
}</p><p>.block-menu li {
display: inline-block;
}
.block-menu li a {
color: #fff;
display: block;
text-decoration: none;
font-family: 'Passion One', Arial, sans-serif;
font-smoothing: antialiased;
text-transform: uppercase;
overflow: visible;
line-height: 20px;
font-size: 24px;
padding: 15px 10px;
}
/* animation domination */
.three-d {
perspective: 200px;
transition: all .07s linear;
position: relative;
cursor: pointer;
}
/* complete the animation! */
.three-d:hover .three-d-box,
.three-d:focus .three-d-box {
transform: translateZ(-25px) rotateX(90deg);
}
.three-d-box {
transition: all .3s ease-out;
transform: translatez(-25px);
transform-style: preserve-3d;
pointer-events: none;
position: absolute;
top: 0;
left: 0;
display: block;
width: 100%;
height: 100%;
}
/*
put the "front" and "back" elements into place with CSS transforms,
specifically translation and translatez
*/
.front {
transform: rotatex(0deg) translatez(25px);
}
.back {
transform: rotatex(-90deg) translatez(25px);
color: #ffe7c4;
}
.front, .back {
display: block;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: black;
padding: 15px 10px;
color: white;
pointer-events: none;
box-sizing: border-box;
}
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 西乌珠穆沁旗| 宁远县| 新闻| 宜阳县| 天台县| 富阳市| 若尔盖县| 义马市| 武宣县| 德阳市| 富宁县| 柞水县| 英吉沙县| 青州市| 从江县| 合水县| 东莞市| 德安县| 塘沽区| 昭通市| 侯马市| 南江县| 东台市| 洪湖市| 体育| 融水| 哈尔滨市| 儋州市| 新蔡县| 六盘水市| 阿图什市| 治多县| 永顺县| 临泉县| 苏州市| 莎车县| 信阳市| 滦南县| 咸宁市| 昌江| 闻喜县|