使用CSS3创建多级导航菜单

时间:2014-12-29

[图片] metal_menu.png

 

02205331_RTyI.jpg[代码] index.html

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en" >
    <head>
        <meta charset="utf-8" />
        <title><A title=CSS3 href="http://www.html5cn.com.cn/css3">CSS3</A> Metal menu with icons | Script Tutorials</title>
        <link rel="stylesheet" href="css/layout.css" type="text/css" media="screen">
        <link rel="stylesheet" href="css/menu.css" type="text/css" media="screen">
    </head>
    <body>
        <div class="container">
            <ul id="nav">
                <li><a href="#"><img src="images/home.png" /> Home</a></li>
                <li><a href="#"><span><img src="images/top1.png" /> HTML/CSS</span></a>
                    <div class="subs">
                        <div class="col">
                            <ul>
                                <li><a href="#"><img src="images/bub.png" /> Link 1</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 2</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 3</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 4</a></li>
                                <li><a href="#"><span><img src="images/top3.png" /> Sublinks</span></a>
                                    <div class="subs">
                                        <div class="col">
                                            <ul>
                                                <li><a href="#"><img src="images/bub.png" /> Link 41</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> Link 42</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> Link 43</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> Link 44</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> Link 45</a></li>
                                            </ul>
                                        </div>
                                        <div class="col">
                                            <ul>
                                                <li><a href="#"><img src="images/bub.png" /> Link 46</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> Link 47</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> Link 48</a></li>
                                                <li><a href="#"><img src="images/bub.png" /> Link 49</a></li>
                                            </ul>
                                        </div>
                                    </div>
                                </li>
                            </ul>
                        </div>
                        <div class="col">
                            <ul>
                                <li><a href="#"><img src="images/bub.png" /> Link 6</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 7</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 8</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 9</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 10</a></li>
                            </ul>
                        </div>
                    </div>
                </li>
                <li><a href="#"><span><img src="images/top2.png" /> <A title=jQuery href="http://www.html5cn.com.cn">jQuery</A>/JS</span></a>
                    <div class="subs">
                        <div class="col">
                            <ul>
                                <li><a href="#"><img src="images/bub.png" /> Link 1</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 2</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 3</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 4</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 5</a></li>
                            </ul>
                        </div>
                        <div class="col">
                            <ul>
                                <li><a href="#"><img src="images/bub.png" /> Link 6</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 7</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 8</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 9</a></li>
                                <li><a href="#"><img src="images/bub.png" /> Link 10</a></li>
                            </ul>
                        </div>
                    </div>
                </li>
                <li><a href="#"><img src="images/top3.png" /> PHP</a></li>
                <li><a href="#"><img src="images/top4.png" /> MySQL</a></li>
                <li><a href="#"><img src="images/top5.png" /> XSLT</a></li>
            </ul>
        </div>
        <footer>
            <h2>CSS3 Metal menu with icons</h2>
            <a href="http://www.script-tutorials.com/css3-metal-menu-with-icons" class="stuts">Back to original tutorial on <span>Script Tutorials</span></a>
        </footer>
    </body>
</html>

 

[代码] css/menu.css

001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
ul#nav {
    display:block;
    float:left;
    font-family:Trebuchet MS,sans-serif;
    font-size:0;
    padding:5px 5px 5px 0;
    background: -moz-linear-gradient(#f5f5f5, #c4c4c4); /* FF 3.6+ */
    background: -ms-linear-gradient(#f5f5f5, #c4c4c4); /* IE10 */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f5f5f5), color-stop(100%, #c4c4c4)); /* Safari 4+, Chrome 2+ */
    background: -webkit-linear-gradient(#f5f5f5, #c4c4c4); /* Safari 5.1+, Chrome 10+ */
    background: -o-linear-gradient(#f5f5f5, #c4c4c4); /* Opera 11.10 */
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f5f5f5', endColorstr='#c4c4c4'); /* IE6 & IE7 */
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#f5f5f5', endColorstr='#c4c4c4')"; /* IE8+ */
    background: linear-gradient(#f5f5f5, #c4c4c4); /* the standard */
}
ul#nav,ul#nav ul {
    list-style:none;
    margin:0;
}
ul#nav,ul#nav .subs {
    background-color:#444;
    border:1px solid #454545;
    border-radius:9px;
    -moz-border-radius:9px;
    -webkit-border-radius:9px;
}
ul#nav .subs {
    background-color:#fff;
    border:2px solid #222;
    display:none;
    float:left;
    left:0;
    padding:0 6px 6px;
    position:absolute;
    top:100%;
    width:300px;
    border-radius:7px;
    -moz-border-radius:7px;
    -webkit-border-radius:7px;
}
ul#nav li:hover>* {
    display:block;
}
ul#nav li:hover {
    position:relative;
}
ul#nav ul .subs {
    left:100%;
    position:absolute;
    top:0;
}
ul#nav ul {
    padding:0 5px 5px;
}
ul#nav .col {
    float:left;
    width:50%;
}
ul#nav li {
    display:block;
    float:left;
    font-size:0;
    white-space:nowrap;
}
ul#nav>li,ul#nav li {
    margin:0 0 0 5px;
}
ul#nav ul>li {
    margin:5px 0 0;
}
ul#nav a:active,ul#nav a:focus {
    outline-style:none;
}
ul#nav a {
    border-style:none;
    border-width:0;
    color:#181818;
    cursor:pointer;
    display:block;
    font-size:13px;
    font-weight:bold;
    padding:8px 18px;
    text-align:left;
    text-decoration:none;
    text-shadow:#fff 0 1px 1px;
    vertical-align:middle;
}
ul#nav ul li {
    float:none;
    margin:6px 0 0;
}
ul#nav ul a {
    background-color:#fff;
    border-color:#efefef;
    border-style:solid;
    border-width:0 0 1px;
    color:#000;
    font-size:11px;
    padding:4px;
    text-align:left;
    text-decoration:none;
    text-shadow:#fff 0 0 0;
    border-radius:0;
    -moz-border-radius:0;
    -webkit-border-radius:0;
}
ul#nav li:hover>a {
    border-style:none;
    color:#fff;
    font-size:13px;
    font-weight:bold;
    text-decoration:none;
    text-shadow:#181818 0 1px 1px;
}
ul#nav img {
    border:none;
    margin-right:8px;
    vertical-align:middle;
}
ul#nav span {
    background-position:right center;
    background-repeat:no-repeat;
    display:block;
    overflow:visible;
    padding-right:0;
}
ul#nav ul span {
    background-image:url("../images/arrow.png");
    padding-right:20px;
}
ul#nav ul li:hover>a {
    border-color:#444;
    border-style:solid;
    color:#444;
    font-size:11px;
    text-decoration:none;
    text-shadow:#fff 0 0 0;
}
ul#nav > li >a {
    background-color:transpa;
    height:25px;
    line-height:25px;
    border-radius:11px;
    -moz-border-radius:11px;
    -webkit-border-radius:11px;
}
ul#nav > li:hover > a {
    background-color:#313638;
    line-height:25px;
}

[文件] source.zip ~ 165KB   下载
 

上一篇:分享css3.0的新属性的参考列表 下一篇:精选 5 个漂亮的 CSS3 图片滑过特效

相关文章

最新文章