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

  1. Outstanding featuresA button should look like a button so that the user knows its function at first glance
  2. The more similar the buttons are to our real buttons, the better. chooserectangular,The rounded rectanglealwaysThe safest option
  3. The up and down or soAlign center
  4. The internal spacing on the left and right sides is twice the vertical spacing, which is one for readabilitySafe proportional selection
  5. The mobile terminalThe smallest pixel button is50 x50 pixelThe left and right sides,The desktopThe smallest pixel button is32 x32 pixels
  6. Inside the button isicon + The textIs more effective than pureThe tooltipIt is better to
  7. The rounded buttonThought thanThe sharpThe edges are friendlier,
  8. If you are using rounded buttons, remember to match the on-screen onesOther elementswithThe 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

  1. Set up the*box-sizing: border-box
  2. Set up thebodyKeep 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.