CSS Selector for <input type=“?”

前端 未结 4 1505
Happy的楠姐
Happy的楠姐 2020-11-28 21:54

Is there any way with CSS to target all inputs based on their type? I have a disabled class I use on various disabled form elements, and I\'m setting the background color fo

4条回答
  •  感动是毒
    2020-11-28 22:39

    Sorry, the short answer is no. CSS (2.1) will only mark up the elements of a DOM, not their attributes. You'd have to apply a specific class to each input.

    Bummer I know, because that would be incredibly useful.

    I know you've said you'd prefer CSS over JavaScript, but you should still consider using jQuery. It provides a very clean and elegant way of adding styles to DOM elements based on attributes.

提交回复
热议问题