What HTML/CSS would you use to create a text input with a background?

前端 未结 7 743
甜味超标
甜味超标 2021-02-03 10:28

I have a website design that includes text input fields that look like this:

Input Field http://img401.imageshack.us/img401/4453/picture1ts2.png

I\'m wondering w

7条回答
  •  [愿得一人]
    2021-02-03 10:58

    okoman has gotten the CSS aspect correct. May I suggest using a to improve the semantic structure of the markup?

    
    
    
    

    Not only is this more accessible, but it provides numerous hooks that you can use for any type of DOM manipulation, validation or field-specific styling in the future.

    Edit: If you don't want the label title displayed for some reason, you can give it a class of 'accessibility' and set the class to display: none; in the CSS. This will allow screen readers to understand the input but hide it from regular users.

提交回复
热议问题