2023-12-10 05:00:01

样式禁用按钮与CSS

我试图改变一个按钮的风格与一个嵌入的图像,如下图所示:

http://jsfiddle.net/krishnathota/xzBaZ/1/

在这个例子中,恐怕没有图像。

我试着:

当按钮被禁用时更改按钮的背景颜色 当按钮被禁用时,更改按钮中的图像 禁用悬停效果时禁用 当您在按钮中单击图像并拖动它时,可以单独看到图像;我想避免这种情况 可以选择按钮上的文本。我也想避免这种情况。

我试着做in button[disabled]。但有些效果是无法消除的。就像 上图:1 px;位置:相对;和图像。


当前回答

在页面中添加以下代码。不改变按钮事件,禁用/启用按钮只需在JavaScript中添加/删除按钮类。

方法1

 <asp Button ID="btnSave" CssClass="disabledContent" runat="server" />

<style type="text/css">
    .disabledContent 
    {
        cursor: not-allowed;
        background-color: rgb(229, 229, 229) !important;
    }

    .disabledContent > * 
    {
        pointer-events:none;
    }
</style>

方法2

<asp Button ID="btnSubmit" CssClass="btn-disable" runat="server" />

<style type="text/css">
    .btn-disable
        {
        cursor: not-allowed;
        pointer-events: none;

        /*Button disabled - CSS color class*/
        color: #c0c0c0;
        background-color: #ffffff;

        }
</style>

其他回答

我认为你应该能够选择一个禁用按钮使用以下:

button[disabled=disabled], button:disabled {
    // your css rules
}

当你的按钮被禁用时,它会直接设置不透明度。首先,我们要设置它的不透明度为

.v-button{
    opacity:1;    
}

为禁用按钮应用灰色按钮CSS。

button[disabled]:active, button[disabled],
input[type="button"][disabled]:active,
input[type="button"][disabled],
input[type="submit"][disabled]:active,
input[type="submit"][disabled] ,
button[disabled]:hover,
input[type="button"][disabled]:hover,
input[type="submit"][disabled]:hover
{
  border: 2px outset ButtonFace;
  color: GrayText;
  cursor: inherit;
  background-color: #ddd;
  background: #ddd;
}

CSS:

.disable{
   cursor: not-allowed;
   pointer-events: none;
}

你可以在那个按钮上添加任何装饰。 要更改状态,可以使用jquery

$("#id").toggleClass('disable');
input[type="button"]:disabled,
input[type="submit"]:disabled,
input[type="reset"]:disabled,
{
  //  apply css here what u like it will definitely work...
}