Home > Web Front-end > CSS Tutorial > Detailed example of mouse over button special effects based on CSS3 animation

Detailed example of mouse over button special effects based on CSS3 animation

巴扎黑
Release: 2017-05-27 17:32:00
Original
1647 people have browsed it

 Brief Tutorial

This is a set of mouse-over button animation special effects made using CSS3 animation. This set of mouse-over button animations has 13 final effects, all of which are created by pseudo-elements of buttons and CSS3 animation.

Detailed example of mouse over button special effects based on CSS3 animation

##View Demo Download plug-in

How to use

HTML structure

This effect uses hyperlinks to create buttons. For example, the HTML code of the first Swipe effect is :

<a class="btn-0" href="#">Swipe</a>
Copy after login

CSS style

## For convenience, the special effects are except , All elements except , , , and have animated transitions added.

html *,
html *:before,
html *:after {
  box-sizing: border-box;
  -webkit-transition: 0.5s;
  transition: 0.5s;
}
html i, html em,
html b, html strong,
html span {
  -webkit-transition: none;
  transition: none;
}
Copy after login

Then set a common style for the button.

a {
  text-decoration: none;
  line-height: 80px;
  color: black;
}
[class^="btn-"] {
  position: relative;
  display: block;
  margin: 20px auto;
  width: 100%;
  height: 80px;
  max-width: 250px;
  text-transform: uppercase;
  overflow: hidden;
  border: 1px solid currentColor;
}
Copy after login

In the first DEMO, use the :before pseudo-element of the button to create a dark purple slider. The slider is absolutely positioned and is located to the left of the button. Its width is 0 at the beginning.

.btn-0 {
  color: #9a3789;
}
.btn-0:before {
  content: &#39;&#39;;
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 80px;
  background: #520c46;
}
Copy after login

When the mouse slides over the button, the font color of the button transitions to white: The width of the before pseudo-element changes from 0 to 100%.

.btn-0:hover {
  color: #e1c4dc;
}
.btn-0:hover:before {
  width: 250px;
}
Copy after login

When the user clicks the button, change the background color of the button to a lighter purple.

.btn-0:active {
  background: #881474;
}
Copy after login

The above is the detailed content of Detailed example of mouse over button special effects based on CSS3 animation. For more information, please follow other related articles on the PHP Chinese website!

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