请教下,能用纯css实现导航按钮hover时滑动下拉出菜单吗

2013-09-02 15:11:19 +08:00
 wandou
5023 次点击
所在节点    问与答
14 条回复
Sivan
2013-09-02 15:12:53 +08:00
当然可以
wandou
2013-09-02 15:16:52 +08:00
@Sivan 求指点。。
alay9999
2013-09-02 15:17:50 +08:00
li:hover ul{

}
alay9999
2013-09-02 15:18:59 +08:00
li ul{
display:none;
}

li:hover ul{
display:block;
}
wandou
2013-09-02 15:20:11 +08:00
@alay9999 滑动怎么做,自上而下滑出来那种
guchengf
2013-09-02 16:05:06 +08:00
CSS3 Transition ,具体方法Google
wandou
2013-09-02 16:11:50 +08:00
@guchengf 刚贴的附言
guchengf
2013-09-02 16:23:59 +08:00
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="a.css">
</head>
<body>
<div>
<ul id="a">111
<li>aaa</li>
<li>bbb</li>
<li>ccc</li>
</ul>
</div>
</body>
</html>



#a li{
list-style: none;
background: black;
color: white;
height: 0px;
-moz-transition: height 2s ease;
-webkit-transition: height 2s ease;
-o-transition: height 2s ease;
transition: height 2s ease;
}
#a:hover li{
height: 20px;
}


上面是HTML,下面是CSS,你看是不是你要的效果
wandou
2013-09-02 16:55:57 +08:00
@guchengf 阿里嘎多,代码都贴出来了: )

不过 高度变化 其实是“伪滑动”

和真实的位移滑动效果差别还是很明显的
alexrezit
2013-09-02 17:07:18 +08:00
@wandou
平移? translate.
wandou
2013-09-02 17:11:58 +08:00
@alexrezit 额,css有translate吗。。没听说过,求详解
Sivan
2013-09-02 18:39:59 +08:00
@wandou 这个不难的,自己研究下吧 :D
alexrezit
2013-09-02 18:42:17 +08:00
@wandou
有啊. 我不是做前端的都知道.
Kaiyuan
2013-09-02 20:11:29 +08:00
单纯滑动只有在导航在最顶部的时候可以,要是不是导航在最顶部的话会「露馅」的。

我当年做了一个3d的。厚颜的卖$3 http://gum.co/suID ,结果没人买,哈哈。
很多网站都有教css3的特效
http://tympanus.net/codrops/ 这个网站有大量的css3、html5、js 特效,可以找到你想要的。
http://www.webdesignerdepot.com/
http://webdesign.tutsplus.com/
http://www.smashingmagazine.com/
http://css-tricks.com/

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/81056

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX