CSS styling input [type=“??”] for select lists [du

2019-04-09 02:29发布

问题:

Possible Duplicate:
CSS Select Selector

What is the CSS equivalent to the following when dealing with select lists?

input[type="text"]
input[type="submit"]

回答1:

The input[type="text"] CSS selector can be broken down into;

  1. input; find all elements that are input elements.
  2. [type="text"]; filter those elements by those which have the type attribute of text.

Because a select box is a <select> element rather than a <input type="select" />, you can just use the select selector as follows;

select {
    /* blah blah blah*/
} 


回答2:

select is not a type of input like those in your example, so you cannot use an attribute selector when you target a select



回答3:

As Fabrizio-Calderan says, select does not have a type property. however, you could use the data-property and style your element based on this

see here : Select elements by data attribute in CSS

Why not using a class to style it?

Pseudo code:

<select>
    <option class="wise">
    <option class="not-so-wise">
    <option class="meh">
</select>


回答4:

select {
   border:1px solid green; 
}

  select option {
     font-weight:bold; 
  }


回答5:

select