How to create a shinny button using HTML and CSS ?
Buttons are undoubtedly one of the most important components of any website or app. A button should be designed in such a way that it stands out of the other component so that it is becoming clear to the user where to click and what is the button used for. There are infinite ways in which a button can be styled. We will be looking at how to create a shinny button. You all might have seen light moving from one end to another and when it gets reflected on some shinny surface. We will be implementing the same thing on mouse-hover.
Approach: The approach is to use pseudo selectors before and after selectors.Using before we will be making strip kind of effect and using after we will make sure it move back and forth give it a reflection kind of look which makes our button look shinny.
HTML Code: In this section, we have created a button.
CSS Code:For CSS, follow the below given steps.
- Step 1: First do some basic styling of button like a background some and border-radius.
- Step 2: Now use inset shadow property to give a shadow to the inside of the border of button.
- Step 3: Now use before selector to create a strip. The trick is to use width less than the actual width of the button and height equal to the actual height of the button. The use of skew function is completely optional, you can skip if you want to. We have used it to have a slightly skewed strip.
- Step 4: Now use hover to move the strip to the left.
- Step 5:Repeat step 3 and 4 with after selector just change the width to negative value to move the strip back to it’s original position.
Tip:You can use some line and length spacing to make some room around the text of the button to give it a more clear look.
Complete Code: It is the combination of the above two sections of the code.
Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML course.