我正在使用Bootstrap,我想要的是将此css应用于我的所有按钮。我尝试了一些代码,但没有一个适合我。顺便说一句,我不想在我的所有按钮中添加class属性。有没有办法做到这一点?
input[type="button"], input[type="submit"] {
//Apply Bootstrap button css here!
}
答案 0 :(得分:1)
如果您正在谈论这些按钮: http://getbootstrap.com/css/#buttons
如果在输入字段中使用.btn
CSS类,则可以使用相同的CSS设计。这是实现您所需要的正确方法。
如果您不想将CSS类应用于输入字段,请输入以下CSS代码:
input[type="button"],
input[type="submit"] {
-moz-user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
display: inline-block;
font-size: 14px;
font-weight: 400;
line-height: 1.42857;
margin-bottom: 0;
padding: 6px 12px;
text-align: center;
vertical-align: middle;
white-space: nowrap;
}
input[type="button"]:focus,
input[type="button"]:active,
input[type="button"]:active:focus,
input[type="submit"]:focus,
input[type="submit"]:active,
input[type="submit"]:active:focus {
outline: thin dotted;
outline-offset: -2px;
}
input[type="button"]:focus,
input[type="button"]:hover,
input[type="submit"]:focus,
input[type="submit"]:hover {
color: #333;
text-decoration: none;
}
input[type="button"]:active,
input[type="submit"]:active {
background-image: none;
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.125) inset;
outline: 0 none;
}
input[type="button"][disabled],
input[type="submit"][disabled] {
box-shadow: none;
cursor: not-allowed;
opacity: 0.65;
pointer-events: none;
}
input[type="button"],
input[type="submit"] {
background-color: #fff;
border-color: #ccc;
color: #333;
}
input[type="button"]:active,
input[type="button"]:focus,
input[type="button"]:hover,
input[type="submit"]:active,
input[type="submit"]:focus,
input[type="submit"]:hover {
background-color: #e6e6e6;
border-color: #adadad;
color: #333;
}
input[type="button"]:active,
input[type="submit"]:active {
background-image: none;
}
input[type="button"][disabled]:active,
input[type="button"][disabled]:focus,
input[type="button"][disabled]:hover,
input[type="submit"][disabled]:active,
input[type="submit"][disabled]:focus,
input[type="submit"][disabled]:hover {
background-color: #fff;
border-color: #ccc;
}
然后,如果您想要蓝色,则需要添加以下内容:
/* Blue */
input[type="button"],
input[type="submit"] {
background-color:#337ab7;
border-color:#2e6da4;
color:#fff;
}
input[type="button"]:active,
input[type="button"]:focus,
input[type="button"]:hover,
input[type="submit"]:active,
input[type="submit"]:focus,
input[type="submit"]:hover, {
background-color:#286090;
border-color:#204d74;
color:#fff;
}
input[type="button"]:active,
input[type="submit"]:active {
background-image: none;
}
input[type="button"][disabled],
input[type="button"][disabled]:active,
input[type="button"][disabled]:focus,
input[type="button"][disabled]:hover,
input[type="submit"][disabled],
input[type="submit"][disabled]:active,
input[type="submit"][disabled]:focus,
input[type="submit"][disabled]:hover {
background-color: #337ab7;
border-color: #2e6da4;
}
如果您需要绿色,请添加以下内容:
/* Green */
input[type="button"],
input[type="submit"] {
background-color:#5cb85c;
border-color:#4cae4c;
color:#fff;
}
input[type="button"]:active,
input[type="button"]:focus,
input[type="button"]:hover,
input[type="submit"]:active,
input[type="submit"]:focus,
input[type="submit"]:hover, {
background-color:#449d44;
border-color:#398439;
color:#fff;
}
input[type="button"]:active,
input[type="submit"]:active {
background-image: none;
}
input[type="button"][disabled],
input[type="button"][disabled]:active,
input[type="button"][disabled]:focus,
input[type="button"][disabled]:hover,
input[type="submit"][disabled],
input[type="submit"][disabled]:active,
input[type="submit"][disabled]:focus,
input[type="submit"][disabled]:hover {
background-color:#5cb85c;
border-color:#4cae4c;
}
如果您需要浅蓝色,请使用以下内容:
/* Light Blue */
input[type="button"],
input[type="submit"] {
background-color:#5bc0de;
border-color:#46b8da;
color:#fff;
}
input[type="button"]:active,
input[type="button"]:focus,
input[type="button"]:hover,
input[type="submit"]:active,
input[type="submit"]:focus,
input[type="submit"]:hover, {
background-color:#31b0d5;
border-color:#269abc;
color:#fff;
}
input[type="button"]:active,
input[type="submit"]:active {
background-image: none;
}
input[type="button"][disabled],
input[type="button"][disabled]:active,
input[type="button"][disabled]:focus,
input[type="button"][disabled]:hover,
input[type="submit"][disabled],
input[type="submit"][disabled]:active,
input[type="submit"][disabled]:focus,
input[type="submit"][disabled]:hover {
background-color:#5bc0de;
border-color:#46b8da;
}
如果您需要橙色,请使用以下内容:
/* Orange */
input[type="button"],
input[type="submit"] {
background-color:#f0ad4e;
border-color:#eea236;
color:#fff;
}
input[type="button"]:active,
input[type="button"]:focus,
input[type="button"]:hover,
input[type="submit"]:active,
input[type="submit"]:focus,
input[type="submit"]:hover, {
background-color:#ec971f;
border-color:#d58512;
color:#fff;
}
input[type="button"]:active,
input[type="submit"]:active {
background-image: none;
}
input[type="button"][disabled],
input[type="button"][disabled]:active,
input[type="button"][disabled]:focus,
input[type="button"][disabled]:hover,
input[type="submit"][disabled],
input[type="submit"][disabled]:active,
input[type="submit"][disabled]:focus,
input[type="submit"][disabled]:hover {
background-color:#f0ad4e;
border-color:#eea236;
}
如果您需要红色,请使用以下内容:
/* Red */
input[type="button"],
input[type="submit"] {
background-color:#d9534f;
border-color:#d43f3a;
color:#fff;
}
input[type="button"]:active,
input[type="button"]:focus,
input[type="button"]:hover,
input[type="submit"]:active,
input[type="submit"]:focus,
input[type="submit"]:hover, {
background-color:#c9302c;
border-color:#ac2925;
color:#fff;
}
input[type="button"]:active,
input[type="submit"]:active {
background-image: none;
}
input[type="button"][disabled],
input[type="button"][disabled]:active,
input[type="button"][disabled]:focus,
input[type="button"][disabled]:hover,
input[type="submit"][disabled],
input[type="submit"][disabled]:active,
input[type="submit"][disabled]:focus,
input[type="submit"][disabled]:hover {
background-color:#d9534f;
border-color:#d43f3a;
}
答案 1 :(得分:0)
您可以使用jQuery执行此操作:
<script type="text/javascript">
$(document).ready(function(){
$.find(":button").each(function (i) {
//Apply bootstarp to i here
}
});
</script>
在此处获取更多想法:how can i get all inputs excluding buttons and hidden fields with jquery?