Share multiple ways to make CSS buttons, with CSS button style code attached

yulia
Release: 2018-09-11 14:31:08
Original
7649 people have browsed it

In the project, almost all websites will use buttons, ranging from a dozen to a few. A practical and good-looking button can add a lot of color to the page, thereby attracting the user's attention. This article mainly talks about the various writing methods of CSS buttons and the beautification of CSS buttons. Finally, a common CSS button style code will be shown for reference. Okay, keep reading!

1. Various ways of writing CSS buttons

CSS buttons can be written directly with button, with a tag, or with input, of course. Using divs, you can use different styles to set the styles you want based on the characteristics of each tag. For example: if you write a button with the a tag, you will definitely use the attribute text-decoration: none. If you use button to write it beautifully, you may use the attribute border: none, etc.

1. Button button (no style)

<button>默认按钮</button>
Copy after login

2. Hyperlink a label button

<a href="#" class="button">链接按钮</a>
Copy after login

CSS part:

.button {
       background-color: #4CAF50;
       color: white;
       padding: 15px 32px;
       text-align: center;
       text-decoration: none;
       display: inline-block;
       font-size: 16px;
   }
Copy after login

3. Button button ( Including style)

<button class="button">按钮</button>
Copy after login

CSS part:

.button {
       background-color: #4CAF50;
       border: none;
       color: white;
       padding: 15px 32px;
       text-align: center;
       font-size: 16px;
       cursor: pointer;
   }
Copy after login
Copy after login

4. Input box button

<input type="button" class="button" value="输入框按钮">
Copy after login

CSS part:

.button {
       background-color: #4CAF50;
       border: none;
       color: white;
       padding: 15px 32px;
       text-align: center;
       font-size: 16px;
       cursor: pointer;
   }
Copy after login
Copy after login

Rendering:

Share multiple ways to make CSS buttons, with CSS button style code attached

2. Common CSS button style codes

Make a very textured metal button. When the user clicks this button, the image on the right will appear. The effect is that the background color becomes darker and the shadow around the button becomes an inner shadow.

.div {
  display: inline-block;
  padding: .3em .5em;
  background-image: linear-gradient(#ddd, #bbb);
  border: 1px solid rgba(0, 0, 0, .2);
  border-radius: .3em;
  box-shadow: 0 1px white inset;
  text-align: center;
  text-shadow: 0 1px 1px black;
  color: white;
  font-weight: bold;
 }
 .div:active {
  box-shadow: .05em .1em .2em rgba(0, 0, 0, .6) inset;
  border-color: rgba(0, 0, 0, .3);
  background: #bbb;
 }
Copy after login

Picture display:

Share multiple ways to make CSS buttons, with CSS button style code attachedShare multiple ways to make CSS buttons, with CSS button style code attached

The above introduces what methods can be used to make buttons, and for the sake of beauty, you What styles can be set? Finally, an example is given for learners’ reference!

The above is the detailed content of Share multiple ways to make CSS buttons, with CSS button style code attached. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template