This is the 27th day of my participation in the August Genwen Challenge.More challenges in August
Author: battleKing warehouse: Github, CodePen blog: CSDN, nuggets feedback email: [email protected] Special statement: original is not easy, shall not be reproduced without authorization or plagiarism, if need to be reproduced can contact the author authorized
background
Buttons are one of the most frequently used interaction elements in programming, and clicking on them produces the action it describes. If a button says submit, clicking on it is likely to submit something. It is also one of the most important interaction elements in any digital product. Now the mainstream button design is still flat design, combined with color changes, animation effects to achieve click feedback.
Excellent submit button features
Outstanding features
A button should look like a button so that the user knows its function at first glance- The more similar the buttons are to our real buttons, the better. choose
rectangular
,The rounded rectangle
alwaysThe safest option
- The up and down or so
Align center
- The internal spacing on the left and right sides is twice the vertical spacing, which is one for readability
Safe proportional selection
The mobile terminal
The smallest pixel button is50 x50 pixel
The left and right sides,The desktop
The smallest pixel button is32 x32 pixels
- Inside the button is
icon
+The text
Is more effective than pureThe tooltip
It is better to The rounded button
Thought thanThe sharp
The edges are friendlier,- If you are using rounded buttons, remember to match the on-screen ones
Other elements
withThe same proportion of rounded corners
The final result
Add HTML files
<ul>
<li>home</li>
<li>products</li>
<li>services</li>
<li>contact</li>
</ul>
Copy the code
2. Add the CSS file
Initialize the page first
- Set up the
*
为box-sizing: border-box
- Set up the
body
Keep the whole project centered
* {
box-sizing: border-box;
}
body {
margin: 0;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: cornsilk;
}
Copy the code
The main CSS code
ul {
padding: 0;
list-style-type: none;
}
ul li {
box-sizing: border-box;
width: 15em;
height: 3em;
font-size: 20px;
border-radius: 0.5 em;
margin: 0.5 em;
box-shadow: 0 0 1em rgba(0.0.0.0.2);
color: white;
font-family: sans-serif;
text-transform: capitalize;
line-height: 3em;
transition: 0.3 s;
cursor: pointer;
}
ul li:nth-child(odd) {
background: linear-gradient(to right, orange, tomato);
text-align: left;
padding-left: 10%;
transform: perspective(500px) rotateY(45deg);
}
ul li:nth-child(even) {
background: linear-gradient(to left, orange, tomato);
text-align: right;
padding-right: 10%;
transform: perspective(500px) rotateY(-45deg);
}
ul li:nth-child(odd):hover {
transform: perspective(200px) rotateY(45deg);
padding-left: 5%;
}
ul li:nth-child(even):hover {
transform: perspective(200px) rotateY(-45deg);
padding-right: 5%;
}
Copy the code
❤️ thank you
If this article is helpful to you, please support it by clicking a “like”. Your “like” is my motivation for writing.
If you like this article, you can “like” + “favorites” + “forward” to more friends.