小编典典

Custom Input [type =“ submit”]样式不适用于jquerymobile按钮

css

我想在带有jquerymobiles按钮的input [type =“ submit”]按钮上使用我的自定义样式,但是它不起作用。我的html代码是:

<input type="submit"  value="Button name">

我的CSS代码是:

input[type="submit"]
{
    border:1px solid red;
    text-decoration:none;
    font-family:helvetica;
    color:red;
    background:url(../images/btn_hover.png) repeat-x;
}

当我使用以下html代码时,将应用相同的样式:

<a href="#" class="selected_btn" data-role="button">Button name</a>

阅读 387

收藏
2020-05-16

共1个答案

小编典典

jQuery Mobile> = 1.4

创建一个自定义类,例如.custom-btn。请注意,要覆盖jQM样式而不使用!important,应遵循CSS层次结构。.ui- btn.custom-class.ui-input-btn.custom-class

.ui-input-btn.custom-btn {
   border:1px solid red;
   text-decoration:none;
   font-family:helvetica;
   color:red;
   background:url(img.png) repeat-x;
}

一个添加data-wrapper-classinput。自定义类将添加到input包装div中。

<input type="button" data-wrapper-class="custom-btn">

jQuery Mobile <= 1.3

Input按钮由具有class的DIV包装ui-btn。您需要选择该div和input[type="submit"]。使用!important对于覆盖Jquery Mobile样式至关重要。

div.ui-btn, input[type="submit"] {
 border:1px solid red !important;
 text-decoration:none !important;
 font-family:helvetica !important;
 color:red !important;
 background:url(../images/btn_hover.png) repeat-x !important;
}
2020-05-16