【发布时间】:2013-02-04 20:48:06
【问题描述】:
我正在尝试创建一个 CSS 按钮并使用 :after 向其添加一个图标,但图像从未显示。如果我用 'background-color:red' 替换 'background' 属性,则会出现一个红色框,所以我不确定这里出了什么问题。
HTML:
<a class="button green"> Click me </a>
CSS:
.button {
padding: 15px 50px 15px 15px;
color: #fff;
text-decoration: none;
display: inline-block;
position: relative;
}
.button:after {
content: "";
width: 30px;
height: 30px;
background: url("http://www.gentleface.com/i/free_toolbar_icons_16x16_black.png") no-repeat -30px -50px no-scroll;
background-color: red;
top: 10px;
right: 5px;
position: absolute;
display: inline-block;
}
.green {
background-color: #8ce267;
}
You can check this fiddle to see what I mean exactly.
感谢任何提示。
【问题讨论】:
标签: css background