Issue
Is it possible to style a button on touch devices using CSS only?
I know :hover
works for adding a style, but I can't remove the style when the user presses off the button and on to the pages background.
Is there a CSS-only solution or would I need to delve into JavaScript?
Solution
You can use :focus
.btn{
border: solid 0px;
color: white;
background-color: blue;
padding: 4px 10px;
font-weight: 450;
font-size: 15px;
}
.btn:hover,
.btn:focus{
cursor: pointer;
background-color: green;
}
<input
class="btn"
type="submit"
value="Button"
>
Try
<body ontouchstart="">
...
</body>
Answered By - Abhishek Pandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.