Can you style html form buttons with css?

后端 未结 6 798
深忆病人
深忆病人 2020-12-01 05:11

I don\'t like the default button style. It\'s really boring. I am using


type buttons. Can I style these some

相关标签:
6条回答
  • 2020-12-01 05:55

    write the below style into same html file head section or write into a .css file

    <style type="text/css">
    .submit input
        {
        color: #000;
        background: #ffa20f;
        border: 2px outset #d7b9c9
        }
    </style>
    
    <input type="submit" class="submit"/>
    

    .submit - in css . means class , so i created submit class with set of attributes
    and applied that class to the submit tag, using class attribute

    0 讨论(0)
  • 2020-12-01 05:56

    You can directly create your own style in this way:

     input[type=button]
     { 
    //Change the style as you like
     }
    
    0 讨论(0)
  • 2020-12-01 06:04

    Yeah, it's pretty simple:

    input[type="submit"]{
      background: #fff;
      border: 1px solid #000;
      text-shadow: 1px 1px 1px #000;
    }
    

    I recommend giving it an ID or a class so that you can target it more easily.

    0 讨论(0)
  • 2020-12-01 06:04

    You might want to add:

    -webkit-appearance: none; 
    

    if you need it looking consistent on Mobile Safari...

    0 讨论(0)
  • 2020-12-01 06:08

    Yes you can target those specificaly using input[type=submit] e.g.

    .myFormClass input[type=submit] {
      margin: 10px;
      color: white;
      background-color: blue;
    }
    
    0 讨论(0)
  • 2020-12-01 06:10

    You can achieve your desired through easily by CSS :-

    HTML

    <input type="submit" name="submit" value="Submit Application" id="submit" />
    

    CSS

    #submit {
        background-color: #ccc;
        -moz-border-radius: 5px;
        -webkit-border-radius: 5px;
        border-radius:6px;
        color: #fff;
        font-family: 'Oswald';
        font-size: 20px;
        text-decoration: none;
        cursor: pointer;
        border:none;
    }
    
    
    
    #submit:hover {
        border: none;
        background:red;
        box-shadow: 0px 0px 1px #777;
    }
    

    DEMO

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