Home > Article > Web Front-end > How to set background image for button in css
In CSS, you can use the "background-image" attribute to set a background image for the button. The function of this attribute is to set the background image of the element. You only need to add "background:url("image path" to the button element );" style is enough.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
How to set the background image for the button in css
In css, you can use the background-image attribute to set the background image of the button. This attribute Sets a background image for the element.
Let’s take an example to see how to set the button background image through the background-image attribute. The example is as follows:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> button { width:200px; height:150px; background-image:url("1118.02.png"); } </style> </head> <body> <button type="button" >按钮</button> </body> </html>
Output result:
(Learning video sharing: css video tutorial)
The above is the detailed content of How to set background image for button in css. For more information, please follow other related articles on the PHP Chinese website!