纯css书签导航按钮
2015-08-02 18:29
1651 查看
最近在写个网站,发现导航栏怎么写都不好看。后来在看别人的网站的时候发现了一个不错的设计,于是乎就想自己去试试如何写出同样的效果。先贴别人网站导航的效果图。
类似书签式的立体导航,瞬间就觉得这个设计真的不错。于是自己就开始思考。如何能用CSS做出同样的效果呢。首先从三角形开始思考。如何生成一个三角形来产生立体效果。于是就想到了border。代码与效果如下。
<!DOCTYPE html>
<body>
<div class="allow">
</div>
</body>
<style>
.allow{
width:1px;
background:white;
border: 15px solid;
border-color: #111111 #B2DE34 #555555 red ;
}
</style>
通过修改border-left,border-right,border-top,border-bottom可以得到不同的三角形。于是乎就开始写书签导航。实现的代码与效果如下。
<li id="info" class="button margin-padding-clear" >
<div id="info-arrow" class="button-content-arrow"></div>
<div id="info-content" class="button-content">学校信息</div>
<div class="button-content-bottom"></div>
</li>
继续说下去既然写了导航。那么肯定需要动画效果于是乎这时候就开始遇到问题了。首先这个书签是由3个div拼成的。用整体动画肯定是不行的。于是就考虑到了动画也两步进行。于是得到如下效果。
实现代码如下:
$(".button").click(function(event){
if(isClickId!=this.id$$this!=null){
$("#"+this.id+"-content").stop(true).animate({width:"120px"},100);
$("#"+this.id+"-arrow").stop(true).animate({right:"120px"},100);
$("#"+isClickId+"-content").stop(true).animate({width:"100px"},100);
$("#"+isClickId+"-arrow").stop(true).animate({right:"100px"},100);
isClickId=this.id;
}
});虽然已经实现了效果。但是个人感觉并不理想。因为一个导航需要3个div。代码太冗杂了。因为自己photoshop的技术确实不咋地。所以不想考虑图片实现效果。希望各位大神能不吝赐教一些简单的实现方法。多谢。
类似书签式的立体导航,瞬间就觉得这个设计真的不错。于是自己就开始思考。如何能用CSS做出同样的效果呢。首先从三角形开始思考。如何生成一个三角形来产生立体效果。于是就想到了border。代码与效果如下。
<!DOCTYPE html>
<body>
<div class="allow">
</div>
</body>
<style>
.allow{
width:1px;
background:white;
border: 15px solid;
border-color: #111111 #B2DE34 #555555 red ;
}
</style>
通过修改border-left,border-right,border-top,border-bottom可以得到不同的三角形。于是乎就开始写书签导航。实现的代码与效果如下。
<li id="info" class="button margin-padding-clear" >
<div id="info-arrow" class="button-content-arrow"></div>
<div id="info-content" class="button-content">学校信息</div>
<div class="button-content-bottom"></div>
</li>
.button-content-arrow{ width:20px; height: 0%; background:white; border: 15px solid; border-color: #888888 #B2DE34 #888888 #888888 ; position: absolute; right:100px; top: 10px; } .button-content{ width: 100px; height: 30px; background-color: #B2DE34; font-size: small; line-height: 30px; text-align: center; position: absolute; top: 10px; right: 0px; } .button-content-bottom{ width:10px; height: 0%; background:white; border: 15px solid; border-color: #fff #fff #fff #58661C; border-top: 0; right: -25px; position: absolute; top: 40px; }
继续说下去既然写了导航。那么肯定需要动画效果于是乎这时候就开始遇到问题了。首先这个书签是由3个div拼成的。用整体动画肯定是不行的。于是就考虑到了动画也两步进行。于是得到如下效果。
实现代码如下:
$(".button").click(function(event){
if(isClickId!=this.id$$this!=null){
$("#"+this.id+"-content").stop(true).animate({width:"120px"},100);
$("#"+this.id+"-arrow").stop(true).animate({right:"120px"},100);
$("#"+isClickId+"-content").stop(true).animate({width:"100px"},100);
$("#"+isClickId+"-arrow").stop(true).animate({right:"100px"},100);
isClickId=this.id;
}
});虽然已经实现了效果。但是个人感觉并不理想。因为一个导航需要3个div。代码太冗杂了。因为自己photoshop的技术确实不咋地。所以不想考虑图片实现效果。希望各位大神能不吝赐教一些简单的实现方法。多谢。
相关文章推荐
- java和javascript获取word文档的书签位置对比
- 使用java为pdf添加书签的方法(pdf书签制作)
- js在PageOffice打开的Word文档光标处插入书签
- 基于WF4.0流程平台开发过程中的知识积累(三)书签实现子流程
- 浏览器书签导入于导出
- 浏览器书签小记
- C# 对Word文档进行处理
- 学生信息管理系统--书签的使用
- 在eclipse中使用 书签
- 兼容性 IBM 芯片内部 真空管
- iPhone 4s手机内部构造
- 矩阵 分配器 切换器 编码器 解码器 中控器
- 经典网页设计:20个新鲜出炉的 HTML5 网站
- ubuntu 下同步google chrome 书签
- 开发实现ArcScene和ArcGlobe由书签创建关键帧
- Html书签的使用
- 新手写的一个书签
- 在Acrobat中利用Javascript根据目录一键生成带页码的书签
- Google Chrome 书签、菜单间距变大
- 喜欢的ios 开发网址