简体   繁体   中英

Styling HTML form controls

How do I style 'reset', 'button' and 'file' input types, let's say with images?

Thank you!

Unfortunately you file button can't be styled without applying a hack , but the other types can be styled like this:

<style type="text/css">
  input[type=button] {
    background-image: url(http://static3.grsites.com/archive/textures/blue/blue003.jpg);
    color: yellow;
    font-weight: bold;
  }

  input[type=reset] {
    background-image: url(http://static2.grsites.com/archive/textures/red/red003.jpg);
    color: yellow;
    font-weight: bold;
  }
</style>

styled.css:

input[@type='button']
{
    background-image: url(button.png);
}

input[@type='reset']
{
    background-image: url(reset.png);
}

input[@type='file']
{
    background-image: url(file.png);
}

HTML

<input type="button" name="buttonname" class="form-button" />

CSS

<style type="text/css">

.form-button
{
  background-image: url(image.gif);
}

</style>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM