This article will share with you how to use CSS to create a button with an image icon. The content is very detailed. Interested friends can take a look.
When displaying an image icon on the button surface, please write code to display the image in the button label. To achieve this effect, use a span tag with display set to an inline block.
The code is as follows:
image-button.css
#buttonImage { background-image:url('/img/search.png'); display:inline-block; margin-top:2px; width:16px; height:16px; } .flatbutton{ border:1px solid #3079ed; background-color:#4d90fe; width:100px; height:28px; }
image-button.html
<!DOCTYPE html> <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <link rel="stylesheet" type="text/css" href="image-button.css" /> </head> <body> <button class="flatbutton"><span id="buttonImage"></span></button> </body> </html>
The effect is as follows:
The above is the detailed content of How to create an image icon button with CSS (with code). For more information, please follow other related articles on the PHP Chinese website!