如何用html5实现左侧是滚动菜单,选中后右边呈现效果

如何用html5实现左侧是滚动菜单,选中后右边呈现效果,第1张

这问题好纠结,最少来个截图啊,给你写个吧,粘过去就行,不行的话留个q,继续问

<!DOCTYPE html>

<html>

 <head>

 <meta charset="utf-8" />

 <title>选项卡</title>

 <style type="text/css">

 ::-webkit-scrollbar{width:0px}

*{ margin:0 padding:0}

ul{

 list-style: none

}

.tab{ 

 width: 600px

 margin: 80px auto

}

.tab .tab_menu{

 float:left

 height: 138px

 width: 90px 

 overflow-y:scroll

}

.tab .tab_menu ul{width:60px}

.tab .tab_menu ul li{

 

 width: 60px

 text-align: center

 line-height: 30px

}

.tab .tab_menu ul li:last-child{

 border-right:none

 width:60px

}

.tab .tab_menu ul li.on{

 background: #999

}

.tab_box{float:left}

.tab .tab_box > div{

 width: 300px

 height: 138px

 border:1px solid #6cf

 display: none //将三个内容框架全隐藏,通过下面的:first-child属性只将第一个框架内容显示出来

}

.tab .tab_box > div:first-child{

 display: block

}

 </style>

 </head>

 <body>

 <!--整体构局说明,用ul完成按钮的横向布局,用div完成三个内容框架的垂直布局(类似于类表),然后将三个内容框架全隐藏,通过下面的:first-child属性只将第一个框架内容显示出来-->

 <div class="tab">

 <div class="tab_menu">

 <ul>

     <li class="on">实事</li>

     <li>政治</li>

     <li>体育</li>

     <li>实事</li>

     <li>政治</li>

     <li>体育</li>

     <li>实事</li>

     <li>政治</li>

     <li>体育</li>

     <li>实事</li>

     <li>政治</li>

     <li>体育</li>

 </ul>

 </div>

 <div class="tab_box">

     <div>实事内容</div>

     <div>政治内容</div>

     <div>体育内容</div>

     <div>实事内容</div>

     <div>政治内容</div>

     <div>体育内容</div>

     <div>实事内容</div>

     <div>政治内容</div>

     <div>体育内容</div>

     <div>实事内容</div>

     <div>政治内容</div>

     <div>体育内容</div>

 </div>

 </div>

 <script type="text/javascript" src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script>

 <script type="text/javascript">

$(function(){

 $(".tab_menu ul li").click(function(){

 $(this).addClass("on").siblings().removeClass("on") //切换选中的按钮高亮状态

 var index=$(this).index() //获取被按下按钮的索引值,需要注意index是从0开始的

 $(".tab_box > div").eq(index).show().siblings().hide() //在按钮选中时在下面显示相应的内容,同时隐藏不需要的框架内容

 })

})

 </script>

 </body>

</html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />

<title></title>

<style>

*{

margin: 0

padding: 0

}

#div{

width: 183px

height: 32px

background: #ffffff

border: 1px solid #444444

overflow: hidden

}

a{

color: #979797

font: bold 14px

text-decoration: none

}

#div,#div ul{

width: 200px

border: none

height: 36px

float: left

}

#div1 {

width: 1200px

float: right

}

#div ul li:hover a{

background: #ff7d93

color: #f6fffc

}

#div ul li a{

display: block

width: 183px

padding-top: 8px

padding-bottom: 8px

background: #ffffff

border: 1px solid #444444

padding: 8px 0 8px 0

margin: 0

}

#div:target{

width: 183px

height: 318px

}

#div1 ul:nth-child(1){

width: 300px

height: 500px

float: right

}

#div1 ul:nth-child(1) li{

width: 300px

height: 100px

clear: both

}

#div1 ul:nth-child(2){

width: 900px

height: 500px

overflow: hidden

float: right

}

#div1 ul:nth-child(2) li{

width: 900px

height: 500px

clear: both

text-align: center

}

</style>

</head>

<body>

<div id="div">

<ul>

<li><a href="#div">友情链接</a></li>

<li><a href="#a1">图一</a></li>

<li><a href="#a2">图二</a></li>

<li><a href="#a3">图三</a></li>

<li><a href="#a4">图四</a></li>

<li><a href="#a5">图五</a></li>

</ul>

</div>

<div id="div1">

<ul>

<li><a href="#a1"><img src="../IMAGE/images(1)/team/member1.jpg" alt="logo..." width="300px"height="100px"/></a></li>

<li><a href="#a2"><img src="../IMAGE/images(1)/team/member2.jpg" alt="logo..." width="300px"height="100px"/></a></li>

<li><a href="#a3"><img src="../IMAGE/images(1)/team/staff1.jpg" alt="logo..." width="300px"height="100px"/></a></li>

<li><a href="#a4"><img src="../IMAGE/images(1)/team/staff2.jpg" alt="logo..." width="300px"height="100px"/></a></li>

<li><a href="#a5"><img src="../IMAGE/images(1)/team/staff3.jpg" alt="logo..." width="300px"height="100px"/></a></li>

</ul>

<ul>

<li id="a1"><img src="../IMAGE/images(1)/team/member1.jpg" alt="logo..."/></li>

<li id="a2"><img src="../IMAGE/images(1)/team/member2.jpg" alt="logo..."/></li>

<li id="a3"><img src="../IMAGE/images(1)/team/staff1.jpg" alt="logo..."/></li>\

<li id="a4"><img src="../IMAGE/images(1)/team/staff2.jpg" alt="logo..."/></li>

<li id="a5"><img src="../IMAGE/images(1)/team/staff3.jpg" alt="logo..."/></li>

</ul>

</div>

</body>

</html>

基本就这样

一共有4种侧滑动画特效。这款CSS3菜单的特点是鼠标划过时即可以各种动画方式展开和隐藏菜单项,该动画方式由CSS3中的transition-delay属性来完成

<style type="text/css">

/*Fontawesome Iconfont*/

@import url(http://libs.useso.com/js/font-awesome/4.0.1/css/font-awesome.min.css)

@import url(http://fonts.useso.com/css?family=Montserrat)

* {margin: 0padding: 0}

li {list-style-type: none}

.grid {float: leftwidth:980pxmargin: 0 auto}

.grid >li { width: 285pxheight: 500pxoverflow: hiddenfloat: leftmargin: 20px 0 20px 30pxposition: relative}

.grid >li:hover {box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.5)}

.grid>li section {position: relativetransition: all 0.25swidth: 100%}

.grid>li h2 {font: bold 14px montserratcolor: #ffftext-transform: uppercaseposition: absolutetext-align: centerwidth: 60%left: 20%top: 100pxpadding: 10px 0border: 2px solid whiteborder-radius: 4px}

.sidenav { position: absolutetop: 0left: 0bottom: 0background: linear-gradient(rgba(50,60,60, 1), rgba(50,60,60, 0.7))width: 50pxtransition: all 0.25soverflow: hiddenpadding-top: 100px}

.sidenav li { _overflow: hiddenwidth: 150px}

.sidenav a { text-decoration: nonecolor: #eee display: blockline-height: 48px }

.sidenav span {display: block}

.sidenav b { padding-left 10pxdisplay: blockcolor: whitefont-family: Montserratfont-size: 12pxline-height: 4opacity: 0}

.sidenav a i { display: blockfloat: leftfont-size: 16pxline-height: 48pxwidth: 50pxtext-align: center}

/*All instances*/

.grid>li:hover .sidenav {width: 150px}

.grid>li:hover section {margin-left: 150px}

.grid>li:hover b {opacity: 1}

.sidenav li:nth-child(1) b, .sidenav li:nth-child(1) a {transition-delay: .08s}

.sidenav li:nth-child(2) b, .sidenav li:nth-child(2) a {transition-delay: .16s}

.sidenav li:nth-child(3) b, .sidenav li:nth-child(3) a {transition-delay: .24s}

.sidenav li:nth-child(4) b, .sidenav li:nth-child(4) a {transition-delay: .32s}

.sidenav li:nth-child(5) b, .sidenav li:nth-child(5) a {transition-delay: .40s}

.sidenav li:nth-child(6) b, .sidenav li:nth-child(6) a {transition-delay: .48s}

/*Three*/

.three .w {transform: perspective(100px) translateZ(-24px)}

.three b {transform: perspective(100px) rotateY(180deg) translateZ(24px) scale(0.5)}

.three:hover b {transform: perspective(100px) rotateY(0) translateZ(24px) scale(1)transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275)background: transparent}

.three .sidenav {width: 150px}

/*Two*/

.two .w {transform: perspective(100px) translateZ(-24px)}

.two b {transform: perspective(100px) rotateX(90deg) translateZ(24px) scale(1.5)opacity: 0}

.two:hover b {transform: perspective(100px) rotateX(0) translateZ(24px) scale(1)transition: all .4sopacity: 1}

.two .sidenav {width: 150px}

/*One*/

.one .w {transform: perspective(100px)}

.one b {transform: perspective(100px) rotateY(90deg)_opacity: 0transform-origin: left center_border: 1px solid white}

.one:hover b {transform: perspective(100px) rotateX(0)transition: all .4sopacity: 1}

.one .sidenav {width: 150px}

.one .sidenav span {float: leftwidth: 100px}

</style>

<!--[if IE]>

<script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>

<![endif]-->

</head>

<body>

<div class="htmleaf-container">

<header class="htmleaf-header bgcolor-11">

<div class="htmleaf-demo center">

<a href="index.html">DEMO1</a>

<a href="index2.html" class="current">DEMO2</a>

<a href="index3.html">DEMO3</a>

<a href="index4.html">DEMO4</a>

</div>

<div style="text-align:centerclear:both">

<script src="/gg_bd_ad_720x90.js" type="text/javascript"></script>

<script src="/follow.js" type="text/javascript"></script>

</div>

</header>

<div class="htmleaf-content bgcolor-8">

<ul class="grid">

<li class="one">

<ul class="sidenav">

<li><a><i class="fa fa-check"></i><span class="w"><b>Tasks</b></span></a></li>

<li><a><i class="fa fa-inbox"></i><span class="w"><b>Messages</b></span></a></li>

<li><a><i class="fa fa-pencil"></i><span class="w"><b>New Post</b></span></a></li>

<li><a><i class="fa fa-cog"></i><span class="w"><b>Settings</b></span></a></li>

<li><a><i class="fa fa-star"></i><span class="w"><b>Starred</b></span></a></li>

<li><a><i class="fa fa-power-off"></i><span class="w"><b>Logout</b></span></a></li>

</ul>

<section>

<h2>Door Opening</h2>

<img src="img/mb1.png"/>

</section>

</li>

<li class="two">

<ul class="sidenav">

<li><a><i class="fa fa-check"></i><span class="w"><b>Tasks</b></span></a></li>

<li><a><i class="fa fa-inbox"></i><span class="w"><b>Messages</b></span></a></li>

<li><a><i class="fa fa-pencil"></i><span class="w"><b>New Post</b></span></a></li>

<li><a><i class="fa fa-cog"></i><span class="w"><b>Settings</b></span></a></li>

<li><a><i class="fa fa-star"></i><span class="w"><b>Starred</b></span></a></li>

<li><a><i class="fa fa-power-off"></i><span class="w"><b>Logout</b></span></a></li>

</ul>

<section>

<h2>Flip Down</h2>

<img src="img/mb2.png"/>

</section>

</li>

<li class="three">

<ul class="sidenav">

<li><a><i class="fa fa-check"></i><span class="w"><b>Tasks</b></span></a></li>

<li><a><i class="fa fa-inbox"></i><span class="w"><b>Messages</b></span></a></li>

<li><a><i class="fa fa-pencil"></i><span class="w"><b>New Post</b></span></a></li>

<li><a><i class="fa fa-cog"></i><span class="w"><b>Settings</b></span></a></li>

<li><a><i class="fa fa-star"></i><span class="w"><b>Starred</b></span></a></li>

<li><a><i class="fa fa-power-off"></i><span class="w"><b>Logout</b></span></a></li>

</ul>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/7281147.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-03
下一篇 2023-04-03

发表评论

登录后才能评论

评论列表(0条)

保存