This question already has an answer here:
- Can I have an onclick effect in CSS? 11 answers
I have a button with a box-shadow that makes it look like it's floating, and I would like to make a pressing effect when I click on it:
Code(CSS):
#startBtn
{
font-family: OpenSans;
color: #FFFFFF;
background-color: #00FF7C;
border: 1px solid #00FF7C;
border-radius: 5px;
box-shadow: 0px 5px 0px #00823F;
}
Code(HTML):
<input type="button" id="startBtn" value="Let's begin">
Screenshot:
IF the buttoms have a fixed height (as it looks) I would wrap the buttom into a div with that height and set the button to position absolute to create the right effect (moving it down) with:
JSFIDDLE
You can use the CSS
hover
property:Another option is to use button generators like buttongarage.in to generate your code for the button and the hover effect.
Use
:active
pseudo class and change the box-shadow vertical offset value. Adjust thetop
value for the activated element with respect to the relatively positioned input with absolute parent.