Adding an image to submit button using CSS

前端 未结 9 2124
面向向阳花
面向向阳花 2020-12-10 05:34

I\'m attempting to use CSS in order to make a sumbit button containing an image. Here\'s the code:

HTML



        
相关标签:
9条回答
  • 2020-12-10 06:25

    instead of input type="submit" you can use input type="image"

    use this one line code

    <input type="image" src="submit.gif" alt="Submit" width="48" height="48">
    

    see DEMO

    0 讨论(0)
  • 2020-12-10 06:26
    <!DOCTYPE html>
    <html>
           <head>
           <style>
                input.search{
                    background-image:url(url.jpg);
                    text-indent:-9999px;
                    width: 100px;
                    height: 30px;
                    border:2px solid rgb(0,102,153);
               }
           </style>
           </head>
    
           <body>
           <input type="submit" class="search" alt="search">
    </body>
    </html> 
    

    enter image description here

    0 讨论(0)
  • 2020-12-10 06:26

    I find this to be the most complete solution:

    #submitbutton {
        background-image: url(http://paulabrown.net/search-button-png-210.png);
        background-repeat: no-repeat;
        height: 24px; // height of image
        width: 24px; // width of image
        padding: 0;
        border: none; // get rid of grey border
        color: transparent; // hide the text (without indenting it to hell)
        background-color: transparent;
        outline: none;
        display: block; // Ensure block element to apply this to inline-elements
    }
    
    0 讨论(0)
提交回复
热议问题