Home > Article > Web Front-end > How to write css picture button code
The background-image attribute can be used to achieve the picture button effect in css. The writing method is "button element {background-image:url (picture path)}"; the background-image attribute is used to set the background image of the element. Use this Just add a background image to the button element using the attribute.
The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.
How to write css picture button code
In css, we can use the background-image attribute to set the picture button, background-image uses For setting the background image of an element.
You only need to add the background-image:url (picture path) style to the button element.
Let’s take a look at the specific operations through examples. The examples are 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:100px; border-radius:20px; border:1px solid #000000; background-image:url(1118.02.png); } </style> </head> <body> <button></button> </body> </html>
Output results:
(Learning video sharing: css video tutorial)
The above is the detailed content of How to write css picture button code. For more information, please follow other related articles on the PHP Chinese website!