html – 是否有可能在按钮上有一个:after伪元素?

前端之家收集整理的这篇文章主要介绍了html – 是否有可能在按钮上有一个:after伪元素?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
参见英文答案 > Why do the :before and :after pseudo-elements require a ‘content’ property?4个
我有一个按钮,在悬停时我想要一个after元素来显示.
但我看不到它.是否可以在按钮上有一个:after元素?

HTML:

@H_301_6@<button class="button button-primary">My button</button>

CSS:

@H_301_6@.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; }

解决方法

这应该适用于所有最新的浏览器.

要使其工作,您需要添加内容:“”;在你的后.

猜你在找的HTML相关文章