純CSS3單頁(yè)切換導(dǎo)航菜單界面設(shè)計(jì)的簡(jiǎn)單實(shí)現(xiàn)

這是一款使用純CSS3制作的單頁(yè)切換導(dǎo)航菜單界面設(shè)計(jì)效果。該頁(yè)面效果中,在頁(yè)面的左側(cè)垂直排放一組導(dǎo)航按鈕,當(dāng)點(diǎn)擊導(dǎo)航按鈕時(shí),相應(yīng)的頁(yè)面會(huì)從屏幕右側(cè)滑動(dòng)出來,效果非常炫酷。
使用方法
HTML結(jié)構(gòu)
該單頁(yè)切換導(dǎo)航菜單界面的HTML結(jié)構(gòu)如下:
- <div class="ct" id="t1">
- <div class="ct" id="t2">
- <div class="ct" id="t3">
- <div class="ct" id="t4">
- <div class="ct" id="t5">
- <ul id="menu">
- <a href="#t1"><li class="icon fa fa-bolt" id="uno"></li></a>
- <a href="#t2"><li class="icon fa fa-keyboard-o" id="dos"></li></a>
- <a href="#t3"><li class="icon fa fa-rocket" id="tres"></li></a>
- <a href="#t4"><li class="icon fa fa-dribbble" id="cuatro"></li></a>
- <a href="#t5"><li class="icon fa fa-plus-circle" id="cinco"></li></a>
- </ul>
- <div class="page" id="p1">
- <section class="icon fa fa-bolt"><span class="title">Bolt</span><span class="hint">...</section>
- </div>
- <div class="page" id="p2">
- <section class="icon fa fa-keyboard-o"><span class="title">Type</span></section>
- </div>
- <div class="page" id="p3">
- <section class="icon fa fa-rocket"><span class="title">Rocket</span></section>
- </div>
- <div class="page" id="p4">
- <section class="icon fa fa-dribbble">
- <span class="title">Dribbble</span>
- <p class="hint">
- Im ready to play, <span class="hint line-trough">invite me </span> find me
- </p>
- <p class="hint">...</p>
- </section>
- </div>
- <div class="page" id="p5">
- <section class="icon fa fa-plus-circle">
- <span class="title">More</span>
- <p class="hint">
- ...
- </p>
- </section>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
CSS樣式
該單頁(yè)切換導(dǎo)航菜單界面使用transform和transition來制作頁(yè)面的切換動(dòng)畫效果。并通過:target偽元素來完成按鈕點(diǎn)擊時(shí)的頁(yè)面切換。完整的CSS代碼如下,代碼中沒有添加瀏覽器廠商的前綴。
- html, body, .page {
- width: 100%;
- height: 100%;
- margin: 0;
- padding: 0;
- transition: all .6s cubic-bezier(.5, .2, .2, 1.1);
- color: #fff;
- overflow: hidden;
- }
- * {
- font-family: 'open sans', 'lato', 'helvetica', sans-serif;
- }
- .page {
- position: absolute;
- }
- #p1 {
- left: 0;
- }
- #p2, #p3, #p4, #p5 {
- left: 200%;
- }
- #p1 { background: darkslateblue; }
- #p2 { background: tomato; }
- #p3 { background: gold; }
- #p4 { background: deeppink; }
- #p5 { background: #9b59b6; }
- #t2:target #p2,
- #t3:target #p3,
- #t4:target #p4,
- #t5:target #p5 {
- transform: translateX(-190%);
- transition-delay: .4s !important;
- }
- #t2:target #p1,
- #t3:target #p1,
- #t4:target #p1,
- #t5:target #p1{
- background: black;
- }
- #t2:target #p1 .icon,
- #t3:target #p1 .icon,
- #t4:target #p1 .icon,
- #t5:target #p1 .icon {
- -webkit-filter: blur(3px);
- filter: blur(3px);
- }
- .icon {
- color: #fff;
- font-size: 32px;
- display: block;
- }
- ul .icon:hover {
- opacity: 0.5;
- }
- .page .icon .title {
- line-height: 2;
- }
- #t2:target ul .icon,
- #t3:target ul .icon,
- #t4:target ul .icon,
- #t5:target ul .icon{
- transform: scale(.6);
- transition-delay: .25s;
- }
- #t2:target #dos,
- #t3:target #tres,
- #t4:target #cuatro,
- #t4:target #cinco {
- transform: scale(1.2) !important;
- }
- ul {
- position: fixed;
- z-index: 1;
- top: 0;
- bottombottom: 0;
- left: 0;
- margin: auto;
- height: 280px;
- width: 10%;
- padding: 0;
- text-align: center;
- }
- #menu .icon {
- margin: 30px 0;
- transition: all .5s ease-out !important;
- }
- a {
- text-decoration: none;
- }
- .title, .hint {
- display: block;
- }
- .title {
- font-size: 38px;
- }
- .hint {
- font-size: 13px;
- }
- #p4 .hint {
- display: inherit !important;
- }
- .hint a {
- color: yellow;
- transition: all 250ms ease-out;
- }
- .hint a:hover {
- color: #FFF;
- }
- .line-trough {
- text-decoration: line-through;
- }
- .page .icon {
- position: absolute;
- top: 0;
- bottombottom: 0;
- rightright: 10%;
- left: 0;
- width: 270px;
- height: 170px;
- margin: auto;
- text-align: center;
- font-size: 80px;
- line-height: 1.3;
- transform: translateX(360%);
- transition: all .5s cubic-bezier(.25, 1, .5, 1.25);
- }
- .page#p1 .icon {
- height: 220px;
- }
- .page#p1 .icon {
- transform: translateX(10%) !important;
- }
- #t2:target .page#p2 .icon,
- #t3:target .page#p3 .icon,
- #t4:target .page#p4 .icon,
- #t5:target .page#p5 .icon {
- transform: translateX(0) !important;
- transition-delay: 1s;
- }
以上這篇純CSS3單頁(yè)切換導(dǎo)航菜單界面設(shè)計(jì)的簡(jiǎn)單實(shí)現(xiàn)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
HTML5實(shí)現(xiàn)響應(yīng)式圓形導(dǎo)航全屏圖片切換
HTML5圓形導(dǎo)航全屏圖片切換是一款基于jQuery跟HTML5制作的全屏圓形導(dǎo)航圖片切換特效。有需要的朋友前來下載使用2019-04-26excel表格如何制作導(dǎo)航欄效果 制作導(dǎo)航欄切換效果的方法
excel是我們常用的辦公軟件,在用excel表格時(shí)有時(shí)會(huì)需要一些導(dǎo)航欄的效果,那么excel表格如何制作導(dǎo)航欄效果?下面小編帶來制作導(dǎo)航欄切換效果的方法,希望對(duì)大家有所幫助2017-12-07CSS實(shí)現(xiàn)導(dǎo)航條Tab切換的三種方法介紹
本篇文章主要介紹了CSS實(shí)現(xiàn)導(dǎo)航條Tab切換的三種方法,包括布局、hover、label,具有一定的參考價(jià)值,有興趣的可以了解一下。2017-01-13純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-13使用layui框架實(shí)現(xiàn)點(diǎn)擊左側(cè)導(dǎo)航切換右側(cè)內(nèi)容且右側(cè)選項(xiàng)卡跟隨變化的效
這篇文章主要介紹了基于HTML5實(shí)現(xiàn)點(diǎn)擊左側(cè)導(dǎo)航切換右側(cè)內(nèi)容且右側(cè)選項(xiàng)卡跟隨變化的效果,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值2020-11-10