How to create an image icon button with CSS (with code)

不言
Release: 2018-11-09 17:47:08
Original
4131 people have browsed it

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;
}
Copy after login

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>
Copy after login

The effect is as follows:

How to create an image icon button with CSS (with code)


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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template