Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have an :after pseudo element on a button? [duplicate]

I have a button and on a :hover I would like an after element to show. But I can't see it. Is it possible to have an :after element on a button?

.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>
like image 201
user1386906 Avatar asked Sep 12 '13 14:09

user1386906


1 Answers

This should now work on all up to date browsers.

To get it to work, you need to add content:""; in your after.

like image 158
Albzi Avatar answered Oct 01 '22 23:10

Albzi