Last active
June 23, 2020 14:24
-
-
Save sseletskyy/7e0adb247e2fae2dfe200c3dd53559c4 to your computer and use it in GitHub Desktop.
Universal hover/active effect for the button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.link { | |
height: 36px; | |
line-height: 36px; | |
display: inline-block; | |
/* position: relative is required for :after to work correctly */ | |
position: relative; | |
background-color: white; | |
color: black; | |
border: 1px solid gray; | |
} | |
.link.selected { | |
background-color: darkgray; | |
color: white; | |
} | |
/* hover is not added in case of touch screen devices */ | |
/* IE does not support @media hover, so -ms-high-contrast for backward compatibility */ | |
@media (hover: hover), (-ms-high-contrast: none) { | |
.link:hover::after { | |
content: '\A'; | |
width: 100%; | |
height: 100%; | |
background: rgba(0, 0, 0, 0.1); | |
position: absolute; | |
top: 0; | |
left: 0; | |
} | |
} | |
/* :active pseudo class should be defined after :hover */ | |
.link:active::after { | |
content: '\A'; | |
width: 100%; | |
height: 100%; | |
background: rgba(0, 0, 0, 0.2); | |
position: absolute; | |
top: 0; | |
left: 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment