Easyui - combo[tree,box]下拉图标有间隙bug解决方法
来源:互联网 发布:淘宝有好货怎么参加 编辑:程序博客网 时间:2024/05/01 09:03
easyui是一个非常好用的js-ui框架,不了解的可以google搜索了解。
easyui的combo以及两个继承的组件combobox,combotree都有一个问题,用不同浏览器的时候才能发现这个问题。
下面看问题图:
放大图:
如果不追求极致,这个不影响使用,但是影响美观。一开始为了解决这个问题,我都用css!import来强制修改宽度。
今天在一个群里问了问,就像大部分群一样,没人回答,他们自顾自的瞎扯。
虽然没有easyui的源码,但是把JS格式化一下照样可以看,最后发现了原因:
_789.appendTo("body");var _78b = _789.find("input.combo-text");var _78c = _789.find(".combo-arrow");var _78d = opts.hasDownArrow ? _78c._outerWidth() : 0;_789._outerWidth(opts.width)._outerHeight(opts.height);_78b._outerWidth(_789.width() - _78d);_78b.css({height: _789.height() + "px",lineHeight: _789.height() + "px"});
上面代码_78b就是这个input,这里设定的outerWidth,这里调用的方法不是jquery的,是easyui自己的方法:
$.fn._outerWidth = function(_e) {if (_e == undefined) {if (this[0] == window) {return this.width() || document.body.clientWidth;}return this.outerWidth() || 0;}return this.each(function() {if ($._boxModel) {$(this).width(_e - ($(this).outerWidth() - $(this).width()));} else {$(this).width(_e);}});};
注意这一行:
$(this).width(_e - ($(this).outerWidth() - $(this).width()));
我在这里计算一下,outerWIdth和width的差值是4,然后在chrome中看源码(此时html还未生成,但是chrome能看到)
看完之后恍然大悟,原来是padding搞的鬼。
.combo .combo-text { font-size: 12px; border: 0px; line-height: 20px; height: 20px; margin: 0; padding: 0px 2px; *margin-top: -1px; *height: 18px; *line-height: 18px; _height: 18px; _line-height: 18px; vertical-align: baseline;}
这里的padding设置两侧都有2px的间隙,导致内外产生了4px的差值。
看到下面几个带*号的针对IE6,7的CSS,这里果断也加上*
*padding: 0px 2px;
经过IE7~9和chrome的测试,完全没有问题,至于IE6,没条件测试就不管了。
- Easyui - combo[tree,box]下拉图标有间隙bug解决方法
- easyui-combo下拉框
- 重新设置Combo Box下拉框宽度
- VC的Combo Box下拉长度
- Combo Box下拉列表框函数
- MFC Combo-Box 控件下拉框问题
- IE6 两个div有间隙的问题(IE 3px bug)解决方法
- combo box
- Combo box
- Combo Box
- Combo Box
- Combo Box
- A Custom Group Combo Box 自定义组合下拉框
- MFC下拉框combo box控件实践笔记
- 如何解决Combo Box下拉菜单长短问题?
- JAVA中的下拉框(Combo Box)概述(1)
- 设置Combo box控件的下拉列表的长度
- MFC下拉框combo box控件实践笔记
- 1.2 《硬啃设计模式》 第2章 学习设计模式需掌握的UML知识
- DecimalFormat(保留两位小数)
- Fragment实现tab功能
- 11.C语言之优先级和连接器
- uva297 第一次又是runtime error 改了数组大小就AC了
- Easyui - combo[tree,box]下拉图标有间隙bug解决方法
- 怎样才能成为一个优秀的产品经理?
- 并查集用法一例
- 连接数据库时报错:无效的列索引
- SQL Server大负载的生产环境下的性能优化:初识元数据优化
- 超极本™ 触摸屏 - 一种全新的动手方式
- arduino之红外
- java.util.concurrent介绍
- JQuery获取当前屏幕的高度宽度的实现代码