jQuery插件jRounded圆角实现javascript给页面元素生成圆角功能
本博客所有文章均属原创作品,如有转载,请注明作者:biuuu,来源:http://www.biuuu.com/?p=750
我们平时使用CSS样式来给页面元素制作圆角效果,但需要使用很多多余的HTML元素,不利于代码的维护,这里介绍一个jQuery插件jRounded圆角,可以轻松给任意元素增加圆角效果,使用非常简单,实例如下:

使用说明
需要使用jQuery库文件和jRounded圆角库文件
需要CSS样式文件,定制你圆角的显示效果,CSS样式代码如下(可修改为需要的效果)
- .box{position:relative;background-color:#eee;margin-bottom:25px;padding:10px;}
- .box .tl,.box .tr,.box .bl,.box .br{position:absolute;width:10px;height:10px;}
- .box .tl{background-image:url(images/box-tl.gif);top:0;left:0;}
- .box .tr{background-image:url(images/box-tr.gif);top:0;right:0;}
- .box .bl{background-image:url(images/box-bl.gif);bottom:0;left:0;}
- .box .br{background-image:url(images/box-br.gif);bottom:0;right:0;}
- .box .bg-white{background-color:#fff;padding:10px;}
使用实例
一,包含文件部分
- <script type="text/javascript" src="jquery.min.js"></script>
- <script type="text/javascript" src="jRounded.js"></script>
- <link rel="stylesheet" href="jRounded.css" />
二,HTML部分
- <div class="biuuu">
- ……需要使用圆角的内容……
- </div>
三,Javascript部分(调用jQuery插件jRounded圆角)
- <script>
- $(document).ready(function() {
- $('.biuuu').box();
- });
- </script>
完整的jQuery插件jRounded圆角JS代码
- (function($){
- $.fn.extend({
- box: function() {
- return $(this).each(function(){
- $(this).wrap('<div class="box"><div></div><div class="tl"></div><div class="tr"></div><div
- class="bl"></div><div class="br"></div></div>');
- });
- }
- })
- })(jQuery);
以上实例可知使用jQuery插件jRounded圆角非常简单,轻松实现javascript给页面元素生成圆角功能。不需要考虑div元素一层与一层之间的关系,简单一行代码实现圆角,值得推荐。
原创文章如转载,请注明:转载自 必优博客 http://www.biuuu.com/
本文链接地址:http://www.biuuu.com/p750.html
Tags:jquery jRounded jquery圆角
作者:biuuu | 分类:jQuery插件 | 评论:0 | 引用:0 | 浏览:2130































我要评论