How to set CSS rules for input, except one type

前端 未结 3 1757
慢半拍i
慢半拍i 2021-01-11 22:05

I have CSS rules for input as

input {
background:#FFFFFF
}
input:hover {
background:#BBBBBB
}

I want to apply this style to al

相关标签:
3条回答
  • 2021-01-11 22:21

    You can just overwrite the general input field style with a new style for submit input fields. Check it out: http://jsfiddle.net/dpYRX/2/

    input {
    background:#FFFFFF
    }
    input:hover {
    background:#BBBBBB
    }
    
    input[type="submit"] {
        background: #ff0000;
    }
    
    input[type="submit"]:hover {
        background: #cdcdcd;
    }
    
    0 讨论(0)
  • 2021-01-11 22:32

    You can use the :not() pseudo-class and an attribute selector, e.g.

    input:not([type=submit]) {
        background: slategray;
    }
    

    Keep in mind there is no support for IE 8 and below.

    http://jsfiddle.net/qpxYb/1/

    0 讨论(0)
  • 2021-01-11 22:37

    You may use the :not() selector.

    input:not([type='submit']):hover {
    /* rules here */
    }
    
    0 讨论(0)
提交回复
热议问题