html - 为什么我在按钮上得到矩形包裹图标?

标签 html css

我创建了带有 background-image 属性的 css 类。

这是 CSS 类:

.showLayers{
    background-image: url("https://cdn0.iconfinder.com/data/icons/flat-online-2/64/layers_server_online_web_internet-128.png");
    background-repeat: no-repeat;
    background-size: 40px 40px;
}

这是我使用的另外两个 css 类:

.miniToolbarContant{
    cursor:pointer;
    width:40px;
    height:40px;
    transition: transform 0.3s;
}

.button_air-medium {
  cursor: pointer;
    height: 65px;
    width: 65px;
    background-color: #fff;
    border-radius: 36px;
    border: 0;
    box-shadow: 5px 5px 5px 0px rgba(0,0,0,0.75);
}

这是 HTML:

<button type="button" class="button_air-medium ">
        <img id="showLayers" class="miniToolbarContant showLayers"/>
</button>

这是它的样子:

enter image description here

这里是 fiddler .

正如您在上图中看到的那样,我用矩形包裹了图标。

我的问题是如何删除包裹图标的矩形?

最佳答案

您将图像定义为 img 标记的背景图像,这没有意义。使用 div 标签代替:https://jsfiddle.net/kbz6opss/1/

关于html - 为什么我在按钮上得到矩形包裹图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45662050/

相关文章:

html - 如何避免将页面元素隐藏在固定元素后面

Javascript 正则表达式去除选择性 html 标签

javascript - 使用 css/html/javascript 将微笑转化为悲伤

HTML/CSS - 将文本与图像和数字对齐

xhtml - 基础 - 在线设置 div 时,是否也 float ?

javascript - jQuery 返回所有页面禁用然后启用

jquery - 使用jquery在页面上搜索并返回结果

jquery - 如何以最佳方式使用 jQuery 删除第一个或最后一个元素的 'n' 数量?

css - Chrome 不尊重使用 :hover pseudo class 更改样式时隐藏的溢出

javascript - jQuery 在 for 循环中附加 300 个 div 有额外的顶部和底部边距