`
chengxianju
  • 浏览: 248262 次
  • 性别: Icon_minigender_1
  • 来自: 合肥
社区版块
存档分类
最新评论

border:0与border:none区别

阅读更多

个人博客地址:http://www.0551it.info

这问题在网络相信已经有不少人问到,最近再次被牵起讨论,籍此记录一下个人的理解,border:none;与border:0;的区别体现有两点:一是理论上的性能差异二是浏览器兼容性的差异。

 

1.性能差异
【border:0;】把border设为“0”像素虽然在页面上看不见,但按border默认值理解,浏览器依然对border-width/border-color进行了渲染,即已经占用了内存值。
【border:none;】把border设为“none”即没有,浏览器解析“none”时将不作出渲染动作,即不会消耗内存值。

2.兼容性差异
兼容性差异只针对浏览器IE6、IE7与标签button、input而言,在win、win7、vista 的XP主题下均会出现此情况。

【border:none;】当border为“none”时似乎对IE6/7无效边框依然存在,
Demo1

【border:0;】当border为“0”时,感觉比“none”更有效,所有浏览器都一致把边框隐藏,如下例Demo2
Demo2

总结:
1. 对比border:0;与border:none;之间的区别在于有渲染和没渲染,感觉他们和display:none;与 visibility:hidden;的关系类似,而对于border属性的渲染性能对比暂时没找测试的方法,虽然认为他们存在渲染性能上的差异但也只能 说是理论上。

2. 如何让border:none;实现全兼容?只需要在同一选择符上添加背景属性即可
demo3

对于border:0;与border:none;个人更向于使用,border:none;,因为border:none;毕竟在性能消耗没有争议,而且兼容性可用背景属性解决不足以成为障碍。

分享到:
评论

相关推荐

    css中border:none;与border:0;的区别说明

    与border:0;的区别体现有两点:一是理论上的性能差异二是浏览器兼容性的差异。 1.性能差异【border:0;】把border设为“0”像素虽然在页面上看不见,但按border默认值理解,浏览器依然对border-width/border-color...

    border:none与border:0使用区别

    无边框用border:none还是border:0一直都是一个热议的问题,两者除了在渲染性能上面的差别以为,在标准浏览器中页面表现是没有任何差别的。下面一起认识一下它们本质的区别

    IE里button设置border:none属性无效解决方法

    本文说明了IE设置border:none属性无效的解决方法,下面给出了二种方法,可以根据情况参考使用

    css类目颜色代码

    border:none;}.skin-box-bd .menu-list .menu .link{background:#AD8260;border:none;border-right:1px solid #FFFFFF;}.all-cats .link{background:#AD8260;border:none;}.all-cats .link:hover{background:#DDDDDD...

    Div+CSS多列布局方法

    border-right:0; height:30px} .myDiv ul{ width:300px; list-style:none; margin:0; padding:0;height:30px} .myDiv ul li{ width:100px; float:left; border-right:1px solid #000; height:30px} .myDiv1{ width:...

    less 实例 z.less

    fieldset, img { border:none; } img{display: block;} address, caption, cite, code, dfn, th, var { font-style:normal; font-weight:normal; } ul, ol { list-style:none; } input { padding-top:0; ...

    jQuery实现居于左侧的弹出菜单

    border:none; cursor:pointer; float:left; background:url(../images/slide-button-active.gif) no-repeat; width:43px; height:117px; text-indent:-999em; outline:none;} .active{background:url(../images/...

    jquery 图片轮播

    background: none repeat scroll 0% 0% rgb(0, 0, 0); opacity: 0.5;"><h2 style="margin: 3px 0px 0px 6px; padding: 0px; font-size: 12px; color: rgb(255, 255, 255); font-family: Verdana; font-weight: bold...

    bbs.qq.com.zip_Wrap Style

    ul,li,form,img {margin:0 padding:0 list-style: none border:none } /* 页面宽幅间距调整 */ .MainTop, .MainBody, .MainFooter {margin:0 10px } .MainTop {padding-top:3px } .MainBody {padding-top:0px } ....

    css 清除浏览器默认样式

    border-spacing:0}a img {border:none;} /* container,clearfix */ .container:after, .clearfix:after {clear:both;content:' ';display:block;font-size:0;line-height:0;visibility:hidden;width:0;height:0;}....

    静态网业模板1

    border:none; cursor:pointer; text-align:center; float:right; color:#FFFFFF; background:url(images/register_bt.gif) no-repeat center; } a.contact{ width:53px; height:24px; display:block; float:right; ...

    数学建模讲座

    border-width:0 8px 8px;display:none;position:absolute;left:7px;top:37px;z-index:1;height:0;width:0;-webkit-animation:gb__a .2s;animation:gb__a .2s}.gb_I{border-color:transparent;border-style:dashed ...

    普通校园网页模板以及一些网站素材

    BORDER-RIGHT: #797fa1 0px solid; BORDER-TOP: #797fa1 0px solid; BORDER-LEFT: #797fa1 0px solid; WIDTH: 80px; BORDER-BOTTOM: #aaaaaa 1px solid; HEIGHT: 12px; BACKGROUND-COLOR: #ffffff } .logininput { ...

    javascript菜单

    border:1px solid #FFF; text-decoration:none; } #caidan>li{ float:left; } #caidan ul{ display:none; } #caidan li{ position:relative; } #caidan ul ul{ position:absolute; top:0px; left:102px...

    右下角广告弹窗1.html

    * {margin:0px;padding:0px;} html,body {height:100%;} body {font-size:14px; line-height:24px;} #tip {position: absolute;right: 0px;bottom: 0px;height: 0px;width: 180px;border: 1px solid #CCCCCC;...

    实时翻译系统html5源码

    border:0;resize:none;outline:0;color:#333;font-family:'微软雅黑';margin:0;padding:0;line-height:40px;font-size:20px;text-indent:10px;} .wrap span.btn{width:140px;height:30px;float:right;margin:10px...

    下拉框美化 美丽的下拉框

    下拉框美化 span.blueCircle_downArrow {overflow:hidden;margin:0;padding:0 20px 0 10px;background:url(blueCircle_bg.gif) no-repeat;vertical-align:middle;...border-width:0 2px;height:100%;}

    简单而且很有用的网页设计

    border-right-style: none; border-bottom-style: solid; border-left-style: none; border-bottom-color: #FC5A00; color: #FFFFFF; } .bk2 { border: 2px groove #0590D1; height: 145px; width: 110px; }...

Global site tag (gtag.js) - Google Analytics