资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

纯CSS3如何实现单页切换导航菜单

这篇文章主要为大家展示了“纯CSS3如何实现单页切换导航菜单”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“纯CSS3如何实现单页切换导航菜单”这篇文章吧。

10多年的浑源网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整浑源建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联建站从事“浑源网站设计”,“浑源网站推广”以来,每个客户项目都认真落实执行。

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

纯CSS3如何实现单页切换导航菜单

 使用方法

 HTML结构

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

  
    
      
        
           
            
              
              
              
              
              
            
            
             Bolt...     
          
                            Type             
                               Rocket             
                                             Dribbble                                    Im ready to play, invite me  find me                  

                 ...

                                                                           More                                    ...                  

                                                                

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: '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如何实现单页切换导航菜单”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联行业资讯频道!


文章题目:纯CSS3如何实现单页切换导航菜单
文章转载:http://cdkjz.cn/article/pcodpc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220