Pure CSS3 color sideline 3D stereo button making tutorial

Source: Internet
Author: User
Tags define relative wrapper

Today we share a use of pure CSS3 implementation of the 3D button, this button is a feature of the color of the sideline, which makes the whole button appears more colorful, not so boring. This article can not only let you see the demo effect, and we also share the production of the tutorial, first look at the effect of the picture:

We can also see the demo demo of these buttons here.

Next to share the production of the tutorial and the source code, the button is mainly composed of HTML and CSS two parts of code, first look at the HTML code:

<button class= "Blue" >     <div class= "wrapper" >        

As you can see, the structure of the HTML code is also very clear, there is no HTML5 element, a button and a few div elements.

Here we define 4 buttons, just like the effect picture, each button has a different color line, we will be in the CSS code to achieve 3D effect and sideline effect.

Next is the CSS code, which first makes a uniform-style rendering of all the button:

button {  Display:block   float:left   margin:0 0 1rem 0;   padding:0;   border:0; &nbsp ;
Height:5rem;
  Width:25rem;
  Border-radius:0.4rem;
  Position:relative;
  Background:transparent;
  Outline:none; button. wrapper {  Display:block   float:left   background: #fff;   border:0;   Height:
5rem;
  Width:25rem;
  Border-radius:0.4rem;
  Position:relative;
  Box-shadow:inset 0-0.3rem 0 0 rgba (0, 0, 0, 0.2), 0 0.1rem 0 0 rgba (0, 0, 0, 0.2);
  Transition:height 0.08s, margin 0.08s, Box-shadow 0.08s, background 0.08s; 
  Background:-moz-linear-gradient (0deg, #4d4d4d 0, #4d4d4d 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100%);   Background:-webkit-linear-gradient (0deg, #4d4d4d 0, #4d4d4d 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 10
0%);   Background:linear-gradient (90deg, #4d4d4d 0, #4d4d4d 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100%); button. wrapper:hover {  background:-moz-linear-gradient (0deg, #333333 0, #333333 2, #ffffff 2, #ffffff 92%, #
F5f5f5 92%, #f5f5f5 100%);   Background:-webkit-linear-gradient (0deg, #333333 0, #333333 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100
%);   Background:linear-gradient (90deg, #333333 0, #333333 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100%); Utton. wrapper:active {  margin-top:0.3rem;   Height:4.7rem;   Box-shadow:none;}

As you can see, the basic look of all the buttons comes out, including the 3D effect.

Then you define the edge color of each button and the style of the mouse over and button pressed:

Button.blue. Wrapper {  background:-moz-linear-gradient (0deg, #7db2e8 0, #7db2e8 2, #ffffff 2, #ffffff 92%, #f5
F5f5 92%, #f5f5f5 100%);   Background:-webkit-linear-gradient (0deg, #7db2e8 0, #7db2e8 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100
%);   Background:linear-gradient (90deg, #7db2e8 0, #7db2e8 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100%);  Utton.blue. wrapper:hover {  background:-moz-linear-gradient (0deg, #5299e0 0, #5299e0 2, #ffffff 2, #ffffff 92%,
#f5f5f5 92%, #f5f5f5 100%);   Background:-webkit-linear-gradient (0deg, #5299e0 0, #5299e0 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100
%);

  Background:linear-gradient (90deg, #5299e0 0, #5299e0 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100%); Button.green. Wrapper {  background:-moz-linear-gradient (0deg, #c4e87d 0, #c4e87d 2, #ffffff 2, #ffffff 92%, #f5
F5f5 92%, #f5f5f5 100%);   Background:-webkit-linear-gradient (0deg, #c4e87d 0%, #c4e87d 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100%);   Background:linear-gradient (90deg, #c4e87d 0, #c4e87d 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100%); Utton.green. wrapper:hover {  background:-moz-linear-gradient (0deg, #b1e052 0, #b1e052 2, #ffffff 2, #ffffff 92%
, #f5f5f5 92%, #f5f5f5 100%);   Background:-webkit-linear-gradient (0deg, #b1e052 0, #b1e052 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100
%);

  Background:linear-gradient (90deg, #b1e052 0, #b1e052 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100%); Button.red. Wrapper {  background:-moz-linear-gradient (0deg, #e87d7d 0, #e87d7d 2, #ffffff 2, #ffffff 92%, #f5f5
F5 92%, #f5f5f5 100%);   Background:-webkit-linear-gradient (0deg, #e87d7d 0, #e87d7d 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100
%);   Background:linear-gradient (90deg, #e87d7d 0, #e87d7d 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100%); Utton.red. Wrapper: hover {  background:-moz-linear-gradient (0deg, #e05252 0, #e05252 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5
F5 100%);   Background:-webkit-linear-gradient (0deg, #e05252 0, #e05252 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100
%);   Background:linear-gradient (90deg, #e05252 0, #e05252 2, #ffffff 2, #ffffff 92%, #f5f5f5 92%, #f5f5f5 100%);

The main code is these, all the source is also shared, download the address >>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.