基于jquery固定于頂部的導(dǎo)航響應(yīng)瀏覽器滾動(dòng)條事件
今天給大家分享一款基于jquery固定于頂部的導(dǎo)航,這款導(dǎo)航當(dāng)瀏覽器滾動(dòng)條位于頂部時(shí),導(dǎo)航高度較高,當(dāng)瀏覽器滾動(dòng)向下滾動(dòng)時(shí),導(dǎo)航高度自動(dòng)減低,并位于頂部。效果圖如下:
實(shí)現(xiàn)的代碼:
html代碼:
<div id="page"> <div id="toolbar" data-0="height:192px" data-128="height: 64px"> <div id="actions"> <div class="icon"> <svg viewbox="0 0 24 24" x="0px" y="0px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="menu"> <path d="M3,18h18v-2H3V18z M3,13h18v-2H3V13z M3,6v2h18V6H3z"> </path> </g> </svg> </div> <div class="spacer"> </div> <div class="icon"> <svg viewbox="0 0 24 24" x="0px" y="0px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="search"> <path d="M15.5,14h-0.8l-0.3-0.3c1-1.1,1.6-2.6,1.6-4.2C16,5.9,13.1,3,9.5,3C5.9,3,3,5.9,3,9.5S5.9,16,9.5,16c1.6,0,3.1-0.6,4.2-1.6l0.3,0.3v0.8l5,5l1.5-1.5L15.5,14z M9.5,14C7,14,5,12,5,9.5S7,5,9.5,5C12,5,14,7,14,9.5S12,14,9.5,14z"> </path> </g> </svg> </div> <div class="icon"> <svg viewbox="0 0 24 24" x="0px" y="0px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g id="more-vert"> <path d="M12,8c1.1,0,2-0.9,2-2s-0.9-2-2-2c-1.1,0-2,0.9-2,2S10.9,8,12,8z M12,10c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S13.1,10,12,10z M12,16c-1.1,0-2,0.9-2,2s0.9,2,2,2c1.1,0,2-0.9,2-2S13.1,16,12,16z"> </path> </g> </svg> </div> </div> <div id="title" data-0="font-size: 48px; padding: 0 0 24px 12px;" data-128="font-size: 18px; padding: 0 0 21px 60px;"> Page Title </div> </div> <div id="content" data-0="padding-top: 192px;" data-192="padding-top: 190px;"> <div class="card"> Content goes here! </div> <div class="card"> Content goes here! </div> <div class="card"> Content goes here! </div> <div class="card"> Content goes here! </div> <div class="card"> Content goes here! </div> <div class="card"> Content goes here! </div> <div class="card"> Content goes here! </div> </div> </div> <script src='jquery.js'></script> <script src='skrollr.min.js'></script> <script> $(document).ready(function () { skrollr.init({ smoothScrolling: true }); }); //@ sourceURL=pen.js </script>
css代碼:
html, body { background: #fafafa; color: #1BBBFB; font-family: sans-serif; } #page { position: absolute; top: 0; right: 0; bottom: 0; left: 0; } #toolbar { display: block; position: fixed; width: 100%; z-index: 10; box-sizing: border-box; -moz-box-sizing: border-box; background-color: #1BBBFB; padding: 0 16px; } #actions { position: relative; display: flex; align-items: center; flex-direction: row; height: 64px; top: 0; left: 0; right 0; } #actions .icon { padding: 7px; margin: 2px; vertical-align: middle; } #actions .spacer { flex: 1; } #actions svg { display: inline-block; pointer-events: none; position: relative; vertical-align: middle; width: 24px; height: 24px; fill: #fff; } #title { padding: 21px; position: absolute; bottom: 0; color: #fff; } #content { display: block; position: relative; padding: 24px; } .card { display: block; position: relative; width: 60%; height: 100px; border: 1px solid #1BBBFB; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; background-color: #fff; margin: 16px auto; padding: 24px; }
- jQuery 頂部導(dǎo)航跟隨滾動(dòng)條滾動(dòng)固定浮動(dòng)在頂部
- jquery scrollTop方法根據(jù)滾動(dòng)像素顯示隱藏頂部導(dǎo)航條
- 基于jquery實(shí)現(xiàn)頁面滾動(dòng)時(shí)頂部導(dǎo)航顯示隱藏
- jquery實(shí)現(xiàn)的一個(gè)導(dǎo)航滾動(dòng)效果具體代碼
- jquery編寫Tab選項(xiàng)卡滾動(dòng)導(dǎo)航切換特效
- jQuery實(shí)現(xiàn)帶滾動(dòng)線條導(dǎo)航效果的方法
- jQuery實(shí)現(xiàn)帶滾動(dòng)導(dǎo)航效果的全屏滾動(dòng)相冊(cè)實(shí)例
- jQuery實(shí)現(xiàn)背景彈性滾動(dòng)的導(dǎo)航效果
- jQuery實(shí)現(xiàn)導(dǎo)航滾動(dòng)到指定內(nèi)容效果完整實(shí)例【附demo源碼下載】
- jQuery滾動(dòng)監(jiān)聽實(shí)現(xiàn)商城樓梯式導(dǎo)航效果
- 使用jQuery.Pin垂直滾動(dòng)時(shí)固定導(dǎo)航
- jQuery實(shí)現(xiàn)的粘性滾動(dòng)導(dǎo)航欄效果實(shí)例【附源碼下載】
相關(guān)文章
基于jquery實(shí)現(xiàn)無限級(jí)樹形菜單
這篇文章主要為大家詳細(xì)介紹了基于jquery實(shí)現(xiàn)無限級(jí)樹形菜單的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-03-03jquery實(shí)現(xiàn)在光標(biāo)位置插入內(nèi)容的方法
這篇文章主要介紹了jquery實(shí)現(xiàn)在光標(biāo)位置插入內(nèi)容的方法,涉及jQuery功能的擴(kuò)展技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-02-02jQuery插件EasyUI校驗(yàn)規(guī)則 validatebox驗(yàn)證框
這篇文章主要介紹了jQuery插件EasyUI校驗(yàn)規(guī)則,主要介紹validatebox驗(yàn)證框,對(duì)validatebox進(jìn)行校驗(yàn)規(guī)則擴(kuò)展,使用jQuery EasyUI的朋友可以參考下。2015-11-11jQuery插件Validate實(shí)現(xiàn)自定義表單驗(yàn)證
這篇文章主要介紹了jQuery插件Validate實(shí)現(xiàn)自定義表單驗(yàn)證,自定義一個(gè)驗(yàn)證方法,感興趣的小伙伴們可以參考一下2016-01-01基于jquery打造的百分比動(dòng)態(tài)色彩條插件
主要是為了往后的項(xiàng)目中方便實(shí)現(xiàn)這類型的功能,在之前做問卷調(diào)查那個(gè)應(yīng)用中,就用到這個(gè)來顯示結(jié)果,但當(dāng)時(shí)開發(fā)時(shí)并不用是插件的,一大堆代碼,看也煩,用起來很麻煩2012-09-09