使用CSS制作立體導(dǎo)航欄
css制作的立體導(dǎo)航欄,具體實(shí)現(xiàn)代碼如下所示:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS制作立體導(dǎo)航</title>
<link rel="stylesheet" href="http://www.w3cplus.com/demo/css3/base.css">
<style>
body{
background: #ebebeb;
}
.nav{
width:560px;
height: 50px;
font:bold 0/50px Arial;
text-align:center;
margin:40px auto 0;
background: #f65f57;
/*制作導(dǎo)航圓角*/
border-radius: 8px;
/*制作導(dǎo)航立體效果*/
box-shadow: 0 7px 0 #ba4a45;
}
.nav a{
display: inline-block;
/* a元素的過(guò)渡屬性:1、設(shè)置所有a標(biāo)簽過(guò)渡;2、過(guò)渡時(shí)間;3、速度曲線:以慢速開(kāi)始的過(guò)渡效果 */
-webkit-transition: all 0.2s ease-in;/* Safari 和 Chrome */
-moz-transition: all 0.2s ease-in;/* Firefox */
-o-transition: all 0.2s ease-in;/* Opera */
-ms-transition: all 0.2s ease-in;/* IE 9 */
transition: all 0.2s ease-in;
}
.nav a:hover{
/* 鼠標(biāo)移上時(shí)的效果;定義2D旋轉(zhuǎn)10度 */
-webkit-transform:rotate(10deg);
-moz-transform:rotate(10deg);
-o-transform:rotate(10deg);
-ms-transform:rotate(10deg);
transform:rotate(10deg);
}
.nav li{
position:relative;
display:inline-block;
padding:0 16px;
font-size: 14px;
text-shadow:1px 2px 4px rgba(0,0,0,.5);
list-style: none outside none;
}
/*制作導(dǎo)航分隔線效果*/
.nav li::before,
.nav li::after{
content:"";
position:absolute;
top:14px;
height: 25px;
width: 1px;
}
.nav li::after{
right: 0;
/* 線性漸變 */
background: -moz-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
background: -webkit-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
background: -o-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
background: -ms-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
background: linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
}
.nav li::before{
left: 0;
background: -moz-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
background: -webkit-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
background: -o-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
background: -ms-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
background: linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
}
/*刪除導(dǎo)航第一個(gè)導(dǎo)航項(xiàng)左邊的分隔線*/
.nav li:first-child::before{
background: none;
}
/*刪除導(dǎo)航最后一個(gè)導(dǎo)航右邊的分隔線*/
.nav li:last-child::after{
background: none;
}
.nav a,
.nav a:hover{
color:#fff;
text-decoration: none;
}
</style>
</head>
<body>
<ul class="nav">
<li><a href="">首頁(yè)</a></li>
<li><a href="">個(gè)人簡(jiǎn)介</a></li>
<li><a href="">作品集</a></li>
<li><a href="">博客</a></li>
<li><a href="">資源</a></li>
<li><a href="">聯(lián)系我</a></li>
</ul>
</body>
</html>
效果圖:


總結(jié):
1、body部分用無(wú)序列表
2、(1)hover
鼠標(biāo)移上時(shí)的效果。
?。?)疑問(wèn)::before和:before的區(qū)別
簡(jiǎn)單來(lái)說(shuō)單冒號(hào)(:)用于CSS3偽類(lèi),雙冒號(hào)(::)用于CSS3偽元素。
w3c關(guān)于css選擇器的規(guī)范:
A pseudo-element is made of two colons (::) followed by the name of the pseudo-element.
This :: notation is introduced by the current document in order to establish a discrimination between pseudo-classes and pseudo-elements. For compatibility with existing style sheets, user agents must also accept the previous one-colon notation for pseudo-elements introduced in CSS levels 1 and 2 (namely, :first-line, :first-letter, :before and :after). This compatibility is not allowed for the new pseudo-elements introduced in CSS level 3.
簡(jiǎn)單翻譯:偽元素由雙冒號(hào)和偽元素名稱(chēng)組成。雙冒號(hào)是在當(dāng)前規(guī)范中引入的,用于區(qū)分偽類(lèi)和偽元素。不過(guò)瀏覽器需要同時(shí)支持舊的已經(jīng)存 在的偽元素寫(xiě)法,比如:first-line、:first-letter、:before、:after等,而新的在CSS3中引入的偽元素則不允許再支持舊的單冒號(hào)的寫(xiě)法。
那么現(xiàn)在就可以完整的回答標(biāo)題中的問(wèn)題了,對(duì)于CSS2之前已有的偽元素,比如:before,單冒號(hào)和雙冒號(hào)的寫(xiě)法::before作用是一樣的。
所以,如果你的網(wǎng)站只需要兼容webkit、firefox、opera等瀏覽器,建議對(duì)于偽元素采用雙冒號(hào)的寫(xiě)法,如果不得不兼容IE瀏覽器,還是用CSS2的單冒號(hào)寫(xiě)法比較安全。
總結(jié)
以上所述是小編給大家介紹的使用CSS制作立體導(dǎo)航欄,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章

html+css+js實(shí)現(xiàn)導(dǎo)航欄滾動(dòng)漸變效果
這篇文章主要介紹了html+css+js實(shí)現(xiàn)導(dǎo)航欄滾動(dòng)漸變效果,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-01-28
這篇文章主要介紹了純CSS實(shí)現(xiàn)導(dǎo)航欄下劃線跟隨效果,本文圖文并茂實(shí)例代碼詳解,給大家介紹的非常詳細(xì),需要的朋友參考下吧2019-12-09html+css 實(shí)現(xiàn)簡(jiǎn)易導(dǎo)航欄功能
這篇文章主要介紹了基于html+css 實(shí)現(xiàn)簡(jiǎn)易導(dǎo)航欄功能,主要就是css(級(jí)聯(lián)樣式表)對(duì)html的內(nèi)容做格式化。具體內(nèi)容詳情大家跟隨小編一起通過(guò)本文學(xué)習(xí)吧2021-04-07
CSS中的導(dǎo)航欄和下拉菜單的實(shí)現(xiàn)
這篇文章主要介紹了CSS中的導(dǎo)航欄和下拉菜單的實(shí)現(xiàn)的相關(guān)資料,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-07-18
純CSS實(shí)現(xiàn)導(dǎo)航欄下劃線跟隨滑動(dòng)效果
這篇文章主要介紹了純CSS實(shí)現(xiàn)導(dǎo)航欄下劃線跟隨滑動(dòng)效果,需要的朋友可以參考下2018-03-29div+css實(shí)現(xiàn)帶箭頭的面包屑導(dǎo)航欄
本文主要介紹了制作漂亮美觀的帶箭頭的面包屑導(dǎo)航欄的示例代碼。具有很好的參考價(jià)值。下面跟著小編一起來(lái)看下吧2017-04-06- 本篇文章主要介紹了CSS導(dǎo)航欄及彈窗示例代碼,導(dǎo)航欄和彈窗是在web中應(yīng)用很廣泛的,非常具有實(shí)用價(jià)值,需要的朋友可以參考下。2017-01-10
純CSS實(shí)現(xiàn)導(dǎo)航欄Tab切換效果
CSS 的強(qiáng)大之處有的時(shí)候超乎我們的想象,Tab 切換,常規(guī)而言確實(shí)需要用到一定的腳本才能實(shí)現(xiàn)。下面看看如何使用純CSS實(shí)現(xiàn)導(dǎo)航欄Tab切換效果2016-10-13CSS利用偽元素實(shí)現(xiàn)導(dǎo)航欄斜線分隔
這篇文章主要介紹了CSS利用偽元素實(shí)現(xiàn)導(dǎo)航欄斜線分隔的相關(guān)資料2016-03-14基于html和CSS3制作簡(jiǎn)單側(cè)邊導(dǎo)航欄
本篇文章給大家分享基于html和CSS3制作簡(jiǎn)單側(cè)邊導(dǎo)航欄,效果簡(jiǎn)單大方,需要的朋友可以從參考下2016-02-25





