Internet Explorer中的锯齿状按钮边缘
时间:2020-03-06 14:53:43 来源:igfitidea点击:
如何从Internet Explorer的宽按钮中去除锯齿状的边缘?例如:
替代文字http://latrine.dgx.cz/images/explorer-buttons6-en.gif
解决方案
解决方法是,可以删除按钮两端的空格,以减少锯齿状边缘。这是通过以下CSS和一些jQuery完成的:
input.button { padding: 0 .25em; width: 0; /* for IE only */ overflow: visible; } input.button[class] { /* IE ignores [class] */ width: auto; }
$(function(){ $('input[type=button]').addClass('button'); });
jQuery用于添加按钮类。在这里可以找到更深入的记录。
我们可以使用CSS更改按钮的边框样式,如下所示:
/************************************************************************** Nav Button format settings **************************************************************************/ .navButtons { font-size: 9px; font-family: Verdana, sans-serif; width: 80; height: 20; position: relative; border-style: solid; border-width: 1; }
我们还可以通过在按钮上设置" background-color"和/或者" border-color"来消除Windows XP的按钮样式(以及Windows的所有其他版本)。
尝试以下样式:
background-color: black; color: white; border-color: red green blue yellow;
当然,我们可以使这更加令人愉悦。但是你明白我的意思了:)
堆栈溢出使用此方法。
我们可以做的不是太多,但是好消息是它已在IE8中修复
http://webbugtrack.blogspot.com/2007/08/bug-101-buttons-render-stretched-and.html
在按钮上设置overflow:visible;
将解决IE 6和7中的问题。
(请参阅http://jehiah.cz/archive/button-width-in-ie)
例外情况
- 在IE 6中,如果还将display:block;应用于按钮,则上述修复方法将无效。在IE 6中将按钮设置为" display:inline;"将使修复工作正常。
- 如果我们在表格单元格中有这样的按钮,则表格单元格将不会收缩为按钮的新的,较小的宽度。我们可以在IE 6中通过在按钮上设置
width:0;
来解决此问题。但是,在IE 7中,这将使按钮文本之外的所有内容消失。 (请参阅http://latrine.dgx.cz/the-stretched-buttons-problem-in-ie)
有关样式按钮的更多信息:
http://natbat.net/2009/Jun/10/styling-buttons-as-links/