CSS如何创建图像图标按钮(附代码)

不言
不言 原创
2018-11-09 17:47:08 3702浏览

本篇文章给大家分享如何用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>

效果如下:

360截图20181109174542301.jpg


以上就是CSS如何创建图像图标按钮(附代码)的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。