Styling an anchor tag to look like a submit button

后端 未结 10 1446
谎友^
谎友^ 2020-11-29 04:19

I have a form where there\'s a \"Submit\" button and a \"Cancel\" anchor. The HTML is this:




        
相关标签:
10条回答
  • 2020-11-29 04:48

    HTML

    <a href="#" class="button"> HOME </a>
    

    CSS

    .button { 
             background-color: #00CCFF;
             padding: 8px 16px;
             display: inline-block;
             text-decoration: none;
             color: #FFFFFF;
             border-radius: 3px;
    }
    .button:hover{ background-color: #0066FF;}
    

    Watch the tutorial

    https://youtu.be/euti4HAJJfk

    0 讨论(0)
  • 2020-11-29 04:48

    How about

    <a href="url"><input type="button" value="Cancel"></a>
    
    0 讨论(0)
  • 2020-11-29 04:50

    Why not just use a button and call the url with JavaScript?

    <input type="button" value="Cancel" onclick="location.href='url.html';return false;" />
    
    0 讨论(0)
  • 2020-11-29 04:57

    Using CSS:

    .button {
        display: block;
        width: 115px;
        height: 25px;
        background: #4E9CAF;
        padding: 10px;
        text-align: center;
        border-radius: 5px;
        color: white;
        font-weight: bold;
    }
    
    <a href="some_url" class="button ">Cancel</a>
    
    0 讨论(0)
  • 2020-11-29 04:59

    Using a button tag instead of the input, resetting it and put a span inside, you'll then just have to style both the link and the span in the same way. It involve extra markup, but it worked for me.

    the markup:

    <button type="submit">
        <span>submit</span>
    </button>
    <a>cancel</a>
    

    the css:

    button[type="submit"] {
        display: inline;
        border: none;
        padding: 0;
        background: none;
    }
    
    0 讨论(0)
  • 2020-11-29 05:02

    I hope this will help.

    <a href="url"><button>SomeText</button></a>
    
    0 讨论(0)
提交回复
热议问题