登录  /  注册
首页 > web前端 > css教程 > 正文

CSS3单页切换导航菜单界面设计的实现详解

高洛峰
发布: 2017-03-04 10:04:30
原创
2237人浏览过

这是一款使用纯css3制作的单页切换导航菜单界面设计效果。该页面效果中,在页面的左侧垂直排放一组导航按钮,当点击导航按钮时,相应的页面会从屏幕右侧滑动出来,效果非常炫酷。

CSS3单页切换导航菜单界面设计的实现详解

 使用方法

 HTML结构

该单页切换导航菜单界面的HTML结构如下:

<p class="ct" id="t1">
  <p class="ct" id="t2">
    <p class="ct" id="t3">
      <p class="ct" id="t4">
         <p 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>
          <p class="page" id="p1">
             <section class="icon fa fa-bolt"><span class="title">Bolt</span><span class="hint">...</section>
          </p>
          <p class="page" id="p2">
            <section class="icon fa fa-keyboard-o"><span class="title">Type</span></section>
          </p>
          <p class="page" id="p3">
            <section class="icon fa fa-rocket"><span class="title">Rocket</span></section>
          </p>
          <p 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>
          </p>
          <p class="page" id="p5">
            <section class="icon fa fa-plus-circle">
              <span class="title">More</span>
              <p class="hint">
                ...   
              </p>
            </section>
          </p>
        </p>
      </p>
    </p>
  </p>
</p>
登录后复制

CSS样式

该单页切换导航菜单界面使用transform和transition来制作页面的切换动画效果。并通过:target伪元素来完成按钮点击时的页面切换。完整的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: &#39;open sans&#39;, &#39;lato&#39;, &#39;helvetica&#39;, 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单页切换导航菜单界面设计的简单实现就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持PHP中文网。

更多CSS3单页切换导航菜单界面设计的实现详解相关文章请关注PHP中文网!

智能AI问答
PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号