【发布时间】:2013-05-03 15:17:33
【问题描述】:
我正在使用 jquery ui 对话框并使用 jquery 添加按钮,如下所示:
$("#151").dialog({
autoOpen: false,
autoResize: true,
buttons: {
"OK": function () {
jQuery(this).dialog('close');
}
}
,
open: function () {
$('.ui-dialog-buttonset').find('button:contains("OK")').focus();
$('.ui-dialog-buttonset').find('button:contains("OK")').addClass('customokbutton');
}
});
自定义按钮类如下所示:
.customokbutton {
text-indent: -9999em; /* hides the text */
color: transparent; /* also hides text */
background-image: url(images/login-icon.png); /*replaces default image */
background-repeat: no-repeat;
background-color: transparent;
background-repeat: no-repeat;
cursor: pointer;
border:none;
height:30px;
outline: none;
}
但是当我将鼠标放在按钮上时,它会向下和向右移动一点。我看到使用 Firebug 时,当我将鼠标移开时会添加以下 css 类(更改位置)
<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only customokbutton" role="button" aria-disabled="false"><span class="ui-button-text">OK</span></button>
当我将鼠标悬停在按钮上时:
<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only customokbutton ui-state-hover" role="button" aria-disabled="false"><span class="ui-button-text">OK</span></button>
而css是这样的:
.ui-state-hover,
.ui-widget-content .ui-state-hover,
.ui-widget-header .ui-state-hover,
.ui-state-focus,
.ui-widget-content .ui-state-focus,
.ui-widget-header .ui-state-focus {
border: 1px solid #707070;
/* background: #dadada;*/
font-weight: normal;
color: #212121;
}
我该如何解决?
【问题讨论】:
-
给我们一个使用 jsfiddle 之类的代码的工作示例
-
而在jquery ui css中
ui-state-hover类是如何定义的? -
@Tallmaris 请检查更新后的 css 问题
-
是的,可能是边框本身导致了这种转变。查看答案以获取可能的修复...
-
这个问题有没有得到解决?我在这个帖子中没有看到任何解决方案,但我有同样的问题。
标签: jquery css jquery-ui stylesheet