您好,登錄后才能下訂單哦!
這篇文章主要介紹AmazeUI如何實現(xiàn)導航條,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
擁有易用的導航條對于任何網(wǎng)站都很重要。本文主要介紹了AmazeUI 導航條的實現(xiàn)示例,分享給大家,具體如下:
<!doctype html> <html class="no-js"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="description" content=""> <meta name="keywords" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>導航條</title> <meta name="renderer" content="webkit"> <meta http-equiv="Cache-Control" content="no-siteapp"/> <link rel="icon" type="image/png" href="assets/i/favicon.png"> <meta name="mobile-web-app-capable" content="yes"> <link rel="icon" sizes="192x192" href="assets/i/app-icon72x72@2x.png"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-title" content="Amaze UI"/> <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png"> <meta name="msapplication-TileImage" content="assets/i/app-icon72x72@2x.png"> <meta name="msapplication-TileColor" content="#0e90d2"> <link rel="stylesheet" href="assets/css/amazeui.min.css"> </head> <body style="margin: 10px;"> <!--默認樣式--> <header class="am-topbar"> <h2 class="am-topbar-brand"> <a href="#">Amaze UI</a> </h2> <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#doc-topbar-collapse'}"><span class="am-sr-only">導航切換</span> <span class="am-icon-bars"></span></button> <div class="am-collapse am-topbar-collapse" id="doc-topbar-collapse"> <ul class="am-nav am-nav-pills am-topbar-nav"> <li class="am-active"><a href="#">首頁</a></li> <li><a href="#">項目</a></li> <li class="am-dropdown" data-am-dropdown> <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;"> 下拉 <span class="am-icon-caret-down"></span> </a> <ul class="am-dropdown-content"> <li class="am-dropdown-header">標題</li> <li><a href="#">1. 去月球</a></li> <li class="am-active"><a href="#">2. 去火星</a></li> <li><a href="#">3. 還是回地球</a></li> <li class="am-disabled"><a href="#">4. 下地獄</a></li> <li class="am-divider"></li> <li><a href="#">5. 橋頭一回首</a></li> </ul> </li> </ul> <form class="am-topbar-form am-topbar-left am-form-inline" role="search"> <div class="am-form-group"> <input type="text" class="am-form-field am-input-sm" placeholder="搜索"> </div> </form> <div class="am-topbar-right"> <div class="am-dropdown" data-am-dropdown="{boundary: '.am-topbar'}"> <button class="am-btn am-btn-secondary am-topbar-btn am-btn-sm am-dropdown-toggle" data-am-dropdown-toggle>其他 <span class="am-icon-caret-down"></span></button> <ul class="am-dropdown-content"> <li><a href="#">注冊</a></li> <li><a href="#">隨便看看</a></li> </ul> </div> </div> <div class="am-topbar-right"> <button class="am-btn am-btn-primary am-topbar-btn am-btn-sm">登錄</button> </div> </div> </header> <!--深色樣式--> <header class="am-topbar am-topbar-inverse"> ... </header> <!--Logo 圖片替換--> <style> .am-topbar .am-text-ir { display: block; margin-right: 10px; height: 50px; width: 125px; background: url(http://a.static.amazeui.org/assets/i/ui/logo.png) no-repeat left center; -webkit-background-size: 125px 24px; background-size: 125px 24px; } </style> <header class="am-topbar am-topbar-inverse"> <h2 class="am-topbar-brand"> <a href="#" class="am-text-ir">Amaze UI</a> </h2> ... </header> <!--頂部固定--> <header class="am-topbar am-topbar-inverse am-topbar-fixed-top"> <div class="am-container"> <h2 class="am-topbar-brand"> <a href="#" class="am-text-ir">Amaze UI</a> </h2> <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#doc-topbar-collapse-4'}"><span class="am-sr-only">導航切換</span> <span class="am-icon-bars"></span></button> <div class="am-collapse am-topbar-collapse" id="doc-topbar-collapse-4"> <ul class="am-nav am-nav-pills am-topbar-nav"> <li class="am-active"><a href="#">首頁</a></li> <li><a href="#">項目</a></li> <li class="am-dropdown" data-am-dropdown> <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;"> 下拉 <span class="am-icon-caret-down"></span> </a> <ul class="am-dropdown-content"> <li><a href="#">帶我去月球</a></li> <li><a href="#">還是回地球</a></li> <li class="am-disabled"><a href="#">臣妾做不到</a></li> </ul> </li> </ul> </div> </div> </header> <!--底部固定--> <header class="am-topbar am-topbar-inverse am-topbar-fixed-bottom"> <div class="am-container"> <h2 class="am-topbar-brand"> <a href="#" class="am-text-ir">Amaze UI</a> </h2> <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#doc-topbar-collapse-5'}"><span class="am-sr-only">導航切換</span> <span class="am-icon-bars"></span></button> <div class="am-collapse am-topbar-collapse" id="doc-topbar-collapse-5"> <ul class="am-nav am-nav-pills am-topbar-nav"> <li class="am-active"><a href="#">首頁</a></li> <li><a href="#">項目</a></li> <li class="am-dropdown am-dropdown-up" data-am-dropdown> <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;"> 上拉 <span class="am-icon-caret-up"></span> </a> <ul class="am-dropdown-content"> <li><a href="#">帶我去月球</a></li> <li><a href="#">還是回地球</a></li> <li class="am-disabled"><a href="#">臣妾做不到</a></li> </ul> </li> </ul> </div> </div> </header> <div style="height: 10000px;"></div> <!--[if (gte IE 9)|!(IE)]><!--> <script src="assets/js/jquery.min.js"></script> <!--<![endif]--> <!--[if lte IE 8 ]> <script src="assets/ie8/jquery.min.js"></script> <script src="assets/ie8/modernizr.js"></script> <script src="assets/js/amazeui.ie8polyfill.min.js"></script> <![endif]--> <script src="assets/js/amazeui.min.js"></script> </body> </html>
效果圖:
AmazeUI各種的導航式菜單與解決方法
一、改造AmazeUI提供的手機端文字橫排菜單
AmazeUI提供的手機端文字橫排菜單的背景顏色是白色的,字體是藍色的,沒有提供相應的class去改寫里面的字體,
我們可以為背景與文字添加一個css,改寫其背景與文字顏色
效果如下:
代碼如下:
<h2>導航菜單-橫排文字式</h2> <style> /*這里是改寫文字的顏色*/ .am-menu-default .am-menu-nav a { color:#222; } /*這里是改寫背景的顏色*/ .am-menu-nav{ background:#f1f1f1; } </style> <div data-am-widget="menu" class="am-menu am-menu-default" > <a href="javascript: void(0)" class="am-menu-toggle a-in-menu"><i class="am-menu-toggle-icon am-icon-bars"></i></a> <!--表示每一個菜單都占3格,也就是在12格1行的布局中占據(jù)4格的位置--> <ul class="am-menu-nav am-avg-sm-3"> <!--表示這個項目帶下拉菜單--> <li class="am-parent"> <a href="#">項目1</a> <ul class="am-menu-sub am-collapse am-avg-sm-4"> <li><a href="#">項目1-1</a></li> <li><a href="#">項目1-2</a></li> <li><a href="#">項目1-3</a></li> <li><a href="#">項目1-4</a></li> <li><a href="#">項目1-5</a></li> <li><a href="#">項目1-6</a></li> </ul> </li> <li><a href="#">項目2</a></li> <li><a href="#">項目3</a></li> <li><a href="#">項目4</a></li> <li class="am-parent"> <a href="#">項目5</a> <ul class="am-menu-sub am-collapse am-avg-sm-4"> <li><a href="#">項目5-1</a></li> <li><a href="#">項目5-2</a></li> <li><a href="#">項目5-3</a></li> <li><a href="#">項目5-4</a></li> <li><a href="#">項目5-5</a></li> <li><a href="#">項目5-6</a></li> </ul> </li> </ul> </div>
二、利用按鈕組與下拉按鈕
這里運用了解決Bootstrap導航欄的思想,《【Bootstrap】導航欄navbar在IE8上的缺陷與解決方案》(點擊打開鏈接),但是AmazeUI的按鈕組與下拉按鈕的復合相當不給力。沒有提供下拉按鈕與按鈕復合的按鈕組。同時,其柵格化布局也無法約束其下拉按鈕的大小,因此,必須自己整幾個div,調(diào)節(jié)其width與margin屬性,規(guī)范其大小。
效果如下:
代碼如下:
<h2>導航菜單-下拉列表式</h2> <style> /*讓每一個下拉按鈕占據(jù)的寬度與居中*/ .am-dropdown{ width:30%; text-align:center; } </style> <!--這里表示一行--> <div style="text-align:center; width:100%; margin-left:-1.5%"> <div class="am-dropdown" data-am-dropdown> <button class="am-btn am-btn-primary am-dropdown-toggle" data-am-dropdown-toggle style="width:110%;" >項目1<span class="am-icon-caret-down"></span></button> <ul class="am-dropdown-content"> <li><a href="#">項目1-1</a></li> <li><a href="#">項目1-2</a></li> <li class="am-divider"></li> <li><a href="#">項目1-3</a></li> </ul> </div> <div class="am-dropdown" data-am-dropdown > <button type="button" class="am-btn am-btn-primary" style="width:110%;" onClick="javascript:window.location.href='#'">項目2</button> </div> <div class="am-dropdown" data-am-dropdown> <button class="am-btn am-btn-primary am-dropdown-toggle" data-am-dropdown-toggle style="width:110%;" >項目3<span class="am-icon-caret-down"></span></button> <ul class="am-dropdown-content"> <li><a href="#">項目3-1</a></li> <li class="am-divider"></li> <li><a href="#">項目3-2</a></li> <li><a href="#">項目3-3</a></li> <li><a href="#">項目3-4</a></li> </ul> </div> </div> <!--搞完一行,必須自己再開一行--> <div style="text-align:center; width:100%; margin-left:-1.5%"> <div class="am-dropdown" data-am-dropdown> <button type="button" class="am-btn am-btn-primary" style="width:110%;" onClick="javascript:window.location.href='#'">項目4</button> </div> <div class="am-dropdown" data-am-dropdown > <button class="am-btn am-btn-primary am-dropdown-toggle" data-am-dropdown-toggle style="width:110%;" >項目5<span class="am-icon-caret-down"></span></button> <ul class="am-dropdown-content"> <li><a href="#">項目5-1</a></li> <li><a href="#">項目5-2</a></li> <li class="am-divider"></li> <li><a href="#">項目5-3</a></li> <li><a href="#">項目5-4</a></li> </ul> </div> <div class="am-dropdown" data-am-dropdown> <button type="button" class="am-btn am-btn-primary" style="width:110%;" onClick="javascript:window.location.href='#'">項目6</button> </div> </div>
這里,每一行最好放置3個組件就好,設(shè)置css為text-align:center,還要補上一個margin-left:-1.5%才剛好其居中,width:100%占據(jù)一行。
其下的各個div占據(jù)30%的寬度。接著的各個按鈕、下拉按鈕其寬度必須是110%,這樣才能剛剛配合好原來的樣式,把按鈕與下拉按鈕符合起來。
其中,里面的li意為分割線。
三、利用無下拉項目的標簽頁
其實手機里面的導航真的無須使用下拉項目。下拉菜單在手機屏幕上是很難點的。直接利用標簽頁設(shè)置一個導航。代碼也短,用戶也不會不滿意。關(guān)鍵是AmazeUI本來就提供這種布局。然后,你再于這個頁面里面布置二級導航也可以。
效果如下:
代碼如下:
<h2>導航菜單-標簽頁布局</h2> <div data-am-widget="tabs" class="am-tabs am-tabs-d2"> <ul class="am-tabs-nav"> <li class="am-active"><a href="#">項目1</a></li> <li><a href="#">項目2</a></li> <li><a href="#">項目3</a></li> <li><a href="#">項目4</a></li> </ul> <ul class="am-tabs-nav"> <li><a href="#">項目5</a></li> <li><a href="#">項目6</a></li> <li><a href="#">項目7</a></li> </ul> </div>
同時,AmazeUI也提供另一種風格的標簽頁布局,效果如下:
代碼如下:
<h2>導航菜單-標簽頁極簡布局</h2> <div data-am-widget="tabs" class="am-tabs am-tabs-default"> <ul class="am-tabs-nav"> <li><a href="#">項目1</a></li> <li><a href="#">項目2</a></li> <li class="am-active"><a href="#">項目3</a></li> </ul> <ul class="am-tabs-nav"> <li><a href="#">項目4</a></li> <li><a href="#">項目5</a></li> <li><a href="#">項目6</a></li> </ul> </div>
最后貼一下整個頁面的效果圖與代碼:
<!--使用HTML5開發(fā)--> <!doctype html> <html class="no-js"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!--自動適應移動屏幕--> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <!--優(yōu)先使用webkit內(nèi)核渲染--> <meta name="renderer" content="webkit"> <!--不要被百度轉(zhuǎn)碼--> <meta http-equiv="Cache-Control" content="no-siteapp"/> <!--以下才是引入amazeui資源--> <link rel="stylesheet" href="assets/css/amazeui.min.css"> <link rel="stylesheet" href="assets/css/app.css"> <!--引入js的時候要注意,必須先引入jQuery,再引入amazeui,因為這個框架是基于jQuery開發(fā)的--> <script src="assets/js/jquery.min.js"></script> <script src="assets/js/amazeui.min.js"></script> <title>導航菜單</title> </head> <body> <h2>導航菜單-橫排文字式</h2> <style> /*這里是改寫文字的顏色*/ .am-menu-default .am-menu-nav a { color:#222; } /*這里是改寫背景的顏色*/ .am-menu-nav{ background:#f1f1f1; } </style> <div data-am-widget="menu" class="am-menu am-menu-default" > <a href="javascript: void(0)" class="am-menu-toggle a-in-menu"><i class="am-menu-toggle-icon am-icon-bars"></i></a> <!--表示每一個菜單都占3格,也就是在12格1行的布局中占據(jù)4格的位置--> <ul class="am-menu-nav am-avg-sm-3"> <!--表示這個項目帶下拉菜單--> <li class="am-parent"> <a href="#">項目1</a> <ul class="am-menu-sub am-collapse am-avg-sm-4"> <li><a href="#">項目1-1</a></li> <li><a href="#">項目1-2</a></li> <li><a href="#">項目1-3</a></li> <li><a href="#">項目1-4</a></li> <li><a href="#">項目1-5</a></li> <li><a href="#">項目1-6</a></li> </ul> </li> <li><a href="#">項目2</a></li> <li><a href="#">項目3</a></li> <li><a href="#">項目4</a></li> <li class="am-parent"> <a href="#">項目5</a> <ul class="am-menu-sub am-collapse am-avg-sm-4"> <li><a href="#">項目5-1</a></li> <li><a href="#">項目5-2</a></li> <li><a href="#">項目5-3</a></li> <li><a href="#">項目5-4</a></li> <li><a href="#">項目5-5</a></li> <li><a href="#">項目5-6</a></li> </ul> </li> </ul> </div> <h2>導航菜單-下拉列表式</h2> <style> /*讓每一個下拉按鈕占據(jù)的寬度與居中*/ .am-dropdown{ width:30%; text-align:center; } </style> <!--這里表示一行--> <div style="text-align:center; width:100%; margin-left:-1.5%"> <div class="am-dropdown" data-am-dropdown> <button class="am-btn am-btn-primary am-dropdown-toggle" data-am-dropdown-toggle style="width:110%;" >項目1<span class="am-icon-caret-down"></span></button> <ul class="am-dropdown-content"> <li><a href="#">項目1-1</a></li> <li><a href="#">項目1-2</a></li> <li class="am-divider"></li> <li><a href="#">項目1-3</a></li> </ul> </div> <div class="am-dropdown" data-am-dropdown > <button type="button" class="am-btn am-btn-primary" style="width:110%;" onClick="javascript:window.location.href='#'">項目2</button> </div> <div class="am-dropdown" data-am-dropdown> <button class="am-btn am-btn-primary am-dropdown-toggle" data-am-dropdown-toggle style="width:110%;" >項目3<span class="am-icon-caret-down"></span></button> <ul class="am-dropdown-content"> <li><a href="#">項目3-1</a></li> <li class="am-divider"></li> <li><a href="#">項目3-2</a></li> <li><a href="#">項目3-3</a></li> <li><a href="#">項目3-4</a></li> </ul> </div> </div> <!--搞完一行,必須自己再開一行--> <div style="text-align:center; width:100%; margin-left:-1.5%"> <div class="am-dropdown" data-am-dropdown> <button type="button" class="am-btn am-btn-primary" style="width:110%;" onClick="javascript:window.location.href='#'">項目4</button> </div> <div class="am-dropdown" data-am-dropdown > <button class="am-btn am-btn-primary am-dropdown-toggle" data-am-dropdown-toggle style="width:110%;" >項目5<span class="am-icon-caret-down"></span></button> <ul class="am-dropdown-content"> <li><a href="#">項目5-1</a></li> <li><a href="#">項目5-2</a></li> <li class="am-divider"></li> <li><a href="#">項目5-3</a></li> <li><a href="#">項目5-4</a></li> </ul> </div> <div class="am-dropdown" data-am-dropdown> <button type="button" class="am-btn am-btn-primary" style="width:110%;" onClick="javascript:window.location.href='#'">項目6</button> </div> </div> <h2>導航菜單-標簽頁布局</h2> <div data-am-widget="tabs" class="am-tabs am-tabs-d2"> <ul class="am-tabs-nav"> <li class="am-active"><a href="#">項目1</a></li> <li><a href="#">項目2</a></li> <li><a href="#">項目3</a></li> <li><a href="#">項目4</a></li> </ul> <ul class="am-tabs-nav"> <li><a href="#">項目5</a></li> <li><a href="#">項目6</a></li> <li><a href="#">項目7</a></li> </ul> </div> <h2>導航菜單-標簽頁極簡布局</h2> <div data-am-widget="tabs" class="am-tabs am-tabs-default"> <ul class="am-tabs-nav"> <li><a href="#">項目1</a></li> <li><a href="#">項目2</a></li> <li class="am-active"><a href="#">項目3</a></li> </ul> <ul class="am-tabs-nav"> <li><a href="#">項目4</a></li> <li><a href="#">項目5</a></li> <li><a href="#">項目6</a></li> </ul> </div> </body> </html>
以上是“AmazeUI如何實現(xiàn)導航條”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。