I am using the active pseudo class for a button and it's not working in iOS only. Works on all desktop browsers and android browsers.
I have used the Safari debugging tools with an iOS device plugged in. If I leverage Forced Pseudo-Classes selecting the Active option, it works as expected. It just doesn't respond with touch.
Pretty Simple, on active it should turn red and move downward on the y-axis.
HTML
<button class="button">
test
</button>
CSS
.button {
display: inline-block;
padding: 100px 100px;
font-size: 24px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #4CAF50;
border: none;
border-radius: 15px;
box-shadow: 0 9px #999;
-webkit-user-select: none;
}
.button:hover {background-color: #3e8e41}
.button:active {
background-color: red;
box-shadow: 0 5px #666;
transform: translateY(4px);
}
http://jsfiddle.net/fzu93c7r/4/
iOS is a bit strange on that. You can use ontouchstart as follows:
<button class="button" ontouchstart>test</button>
Or the pseudo :target (works for <a> tags)
.button:target {
background-color: red; box-shadow: 0 5px #666; transform:
translateY(4px);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With