CSS selector for text input fields?

后端 未结 9 754
广开言路
广开言路 2020-12-07 07:46

How can I target input fields of type \'text\' using CSS selectors?

相关标签:
9条回答
  • 2020-12-07 08:20

    I usually use selectors in my main stylesheet, then make an ie6 specific .js (jquery) file that adds a class to all of the input types. Example:

    $(document).ready(function(){
      $("input[type='text']").addClass('text');
    )};
    

    And then just duplicate my styles in the ie6 specific stylesheet using the classes. That way the actual markup is a little bit cleaner.

    0 讨论(0)
  • 2020-12-07 08:21

    input[type=text]

    This will select all the input type text in a web-page.

    0 讨论(0)
  • 2020-12-07 08:23

    The attribute selectors are often used for inputs. This is the list of attribute selectors:

    [title] All elements with the title attribute are selected.

    [title=banana] All elements which have the 'banana' value of the title attribute.

    [title~=banana] All elements which contain 'banana' in the value of the title attribute.

    [title|=banana] All elements which value of the title attribute starts with 'banana'.

    [title^=banana] All elements which value of the title attribute begins with 'banana'.

    [title$=banana] All elements which value of the title attribute ends with 'banana'.

    [title*=banana] All elements which value of the title attribute contains the substring 'banana'.

    Reference: https://kolosek.com/css-selectors/

    0 讨论(0)
提交回复
热议问题