Home  >  Article  >  Web Front-end  >  How to set background image for button in css

How to set background image for button in css

WBOY
WBOYOriginal
2021-11-26 16:40:548521browse

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.

How to set background image for button in css

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:

How to set background image for button in css

(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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn