【发布时间】:2013-09-17 00:55:36
【问题描述】:
我有一个按钮,在 :hover 上我想显示一个 after 元素。但我看不到它。按钮上可以有:after 元素吗?
.button {
cursor: pointer;
height: 30px;
}
.button-primary {
border: none;
}
.button-primary:hover:after {
display: block;
position: relative;
top: 3px;
right: 3px;
width: 100px;
height: 5px;
}
<button class="button button-primary">My button</button>
【问题讨论】:
-
不要忘记
content:"";在您的:after。 -
@BeatAlex 这就是为什么伪元素没有出现的答案。
-
您在 sn-p @feeela 末尾缺少
} -
@BeatAlex 可能只是一个复制/粘贴错误,因为这是 SASS 语法,并且在原始右括号之前可能有更多定义。不过提示很好。
-
确保您注意您实际使用的元素。按钮元素应该允许它,但其他 replaced 元素,如 input、img、textarea、select 等则不允许。
标签: html css pseudo-element