<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>
这个可以通过绝对定位,配合left设置 或者translate去实现left的方法:
比如让class为menu的元素宽为300px,高100%的,设置left为-300px;在这期间可以加一个过渡transition:left 0.3s ...;
然后让class为menu active的元素设置 left设置为0就可以了 ,在这期间可以加一个过渡transition:left 0.3s ...;
然后可以通过Jquery的toggleClass('active')来实现切换
translate
比如让class为menu的元素宽为300px,高100%的,设置left为-300px;在这期间可以加一个过渡transition:left 0.3s ...;
然后让class为menu active的元素设置 transform:translate3d(-300px,0,0) ,在这期间可以加一个过渡transition:left 0.3s ...;
然后可以通过Jquery的toggleClass('active')来实现切换
这个过程中 需要注意 body需要overflow:hidden(不然会有滚动条,可设置overflow-x即可)
left 和 translate 最好用translate ,translate3d可以开启GPU硬件加速,性能会更好,体验会更流畅
我github有类似小组件样式
github: IFmiss
希望能解决你的问题
建议使用FF,Safari,举个例子:<!doctype html>
<html>
<head>
<title>HTML5+CSS3+JavaScript</title>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />
<meta http-equiv="Content-Type" content="text/htmlcharset=gbk" />
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<style type="text/css">
body {
behavior: url(ie-css3.htc)
}
* {margin:0 autopadding:0}
body {font-size:13pxfont-family:Arial}
ul li {list-style:none}
#menu {
width:982px
height:35px
margin-top:20pxdisplay:block
background: #e3e3e3
background: -moz-linear-gradient(top, #ccc, #999)
background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#999))
-moz-box-shadow: 1px 1px 3px #333
-webkit-box-shadow: 1px 1px 3px #333
box-shadow: 1px 1px 3px #333
-webkit-border-top-left-radius:4px
-webkit-border-top-right-radius:4px
-moz-border-radius-topleft:4px
-moz-border-radius-topright:4px
-webkit-border-bottom-left-radius:4px
-webkit-border-bottom-right-radius:4px
-moz-border-radius-bottomleft:4px
-moz-border-radius-bottomright:4px
-o-border-radius:4px
-khtml-border-radius:4px
text-shadow: 0 1px 0 white
}
#menu ul {
margin-left:0
}
#menu ul li {
display:inline
}
#menu ul li a:link, a:visited {
text-align:centerfloat:leftwidth:6.8emtext-decoration:nonepadding:7.5px 0.75emfont-size:16pxfont-weight:boldmargin-top:0pxborder-right:1px solid #ccccolor: #454545
}
#menu ul li a:hover {
text-decoration:none
background:-webkit-gradient(linear, left top, left bottom, from(#333), to(#ccc))
background: -moz-linear-gradient(top, #333, #ccc)
-webkit-background-size:0 35px
color: #ddd
text-shadow: 0 1px 0 black
}
.text {
border:1px solid graywidth:150pxheight:17pxposition:relativetop:8pxleft:13pxfont-family:Arial
-webkit-border-top-left-radius:90px
-webkit-border-top-right-radius:90px
-moz-border-radius-topleft:90px
-moz-border-radius-topright:90px
-webkit-border-bottom-left-radius:90px
-webkit-border-bottom-right-radius:90px
-moz-border-radius-bottomleft:90px
-moz-border-radius-bottomright:90px
-o-border-radius:90px
-khtml-border-radius:90px
}
</style>
<script language="JavaScript" type="text/javascript">
(function()
{
if(!0)
return
var e = "abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog, eventsource,figure,footer,hgroup,header,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=0,length=e.length
while(i<length)
{
document.createElement_x(e[i++])
}
})()
</script>
</head>
<body>
<menu id="menu"><form action="index.php" method="get">
<ul>
<li><a href="#" title="HomePage">HomePage</a></li>
<li><a href="#" title="Introuduce">Introuduce</a></li>
<li><a href="#" title="Products">Products</a></li>
<li><a href="#" title="My album">My album</a></li>
<li><a href="#" title="Shopping">Shopping</a></li>
<li><a href="#" title="Contact our">Contact our</a></li>
</ul>
<input type="search" class="text" value="search..." /></form>
</menu>
<body>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)