Home  >  Article  >  Web Front-end  >  css3 mouse-in special effects: how to achieve div color gradient and zoom-in effects

css3 mouse-in special effects: how to achieve div color gradient and zoom-in effects

坏嘻嘻
坏嘻嘻Original
2018-09-21 11:09:0010968browse

The content of this article is about how to use transition in CSS3 to achieve the effect of changing the color, height and width of the div when the mouse is hovering. It has certain reference value. Friends in need can refer to it. , hope it helps you.

We usually see such a situation when browsing web pages: when the mouse hovers over a certain area, the shape of the area will be enlarged or reduced within a specified time, and even There will be a color gradient as the size changes. How is this special effect achieved? Now let me introduce to you how to use the transition attribute and hover attribute to achieve the effect of div color gradient and zoom in and out in CSS3.

#The transition attribute in css3

The transition attribute is an abbreviated attribute, used for four transition attributes, namely transition-property, transition- duration, transition-timing-function and transition-delay.

  1. transition-property: The style to be moved (the default value is all, there are three definitions: all, attr and none)

  2. transition-duration: Movement time (only movement time is a required value and cannot be 0, otherwise transition will not have any effect)

  3. transition-timing-function: Movement form (usage includes the following six)

            ease: (gradually slows down)
                linear: (uniform speed)
                ease-in (Accelerate)
    Ease-out: (Decelerate)
    Ease-in-out: (Accelerate first and then decelerate)
    cubic-bezier Bezier curve: (x1, y1, x2, y2)

    Note: If it is not defined, the default value of transition-timing-function is ease.

  4. transition-delay: delay time (default value is 0)

transition attribute Compatible with browsers (according to W3C standards)

css3 mouse-in special effects: how to achieve div color gradient and zoom-in effects

#Higher versions of browsers such as Internet Explorer 10, Firefox, Opera, and Chrome support the standard way of writing the transition attribute. Safari supports an alternative -webkit-transition attribute. However, Internet Explorer 9 and earlier browsers do not support the transition attribute.

css3 mouse-in special effect implementation code

<!DOCTYPE html>
<html>
 <head>
    <meta charset="UTF-8">
    <title>transition</title>
    <style>
      .box{
          width:100px;
          height:100px;
          background-color:blue;
          transition-duration:2s;
          transition-timing-function:ease;
          transition-delay:0s;
          transition-property:all;
          }
     .box:hover{
          width:200px;
          height:200px;
          background-color:red;
                }
    </style>
 </head>
  <body>
         <div class="box"></div>
   </body>
</html>

The css3 mouse-in special effect implementation effect is as shown in the figure
css3 mouse-in special effects: how to achieve div color gradient and zoom-in effects

More cool CSS3, html5, javascript special effects codes, all in:

javascript special effects collection

The above is the detailed content of css3 mouse-in special effects: how to achieve div color gradient and zoom-in effects. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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