CSS创建图像图标按钮的方法

这篇文章主要介绍了CSS创建图像图标按钮的方法,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获。下面让小编带着大家一起了解一下。

在按钮表面上显示图像图标时,请写代码以在按钮标签中显示图像,实现此效果要使用显示设置为内联块的span标记。

代码如下:

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>

效果如下:

CSS创建图像图标按钮的方法

感谢你能够认真阅读完这篇文章,希望小编分享CSS创建图像图标按钮的方法内容对大家有帮助,同时也希望大家多多支持亿速云,关注行业资讯频道,遇到问题就找亿速云,详细的解决方法等着你来学习!