Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

CSS3 Transitions: A Small Tutorial

DZone's Guide to

CSS3 Transitions: A Small Tutorial

· Web Dev Zone
Free Resource

Learn how to build modern digital experience apps with Crafter CMS. Download this eBook now. Brought to you in partnership with Crafter Software

  • "Transition" refers to a change of the state of an object.
  • In CSS3 we can show the transition of an object using a transition property. Variations of this property for different browsers are:  transition,-moz-transition, -moz-transform ,-webkit-transition, -webkit-transform,-o-transition.
  • The other transition properties have duration, property, delay and timing functions to control the CSS3 transition.

Testing CSS3 Transition:-

  • The HTML CSS3 transition code css3Demo.html ,
    <!DOCTYPE html>
    <html>
         
        <head>
            <title>CSS3 Transition Demo</title>
            <style>
                div.name {
                    color:white;
                    text-align:center;
                    padding:100px;
                    width:100px;
                    height:75px;
                    background:black;
                    border:4px solid red;
                    border-radius:0px;
                    transition:border 2s, border-radius 2s, color 2s;
                    -moz-transition:border 2s, border-radius 2s;
                    -webkit-transition:border 2s, border-radius 2s;
                    -o-transition:border 2s, border-radius 2s;
                }
                div.name:hover {
                    border-radius:400px;
                    border:4px solid yellow;
                    background:green;
                    color:yellow;
                }
            </style>
        </head>
         
        <body>
            <div class="name">SANDEEP</div>
        </body>
     
    </html>
  • Firebug Inspection ,

Output:

  • It displays the square on "LOAD" of HTML page,
  • On "HOVER" of that div element the transition occurs and becomes round with change in border radius,color and border style. The result will look like:
          
          

Crafter is a modern CMS platform for building modern websites and content-rich digital experiences. Download this eBook now. Brought to you in partnership with Crafter Software.

Topics:

Published at DZone with permission of Sandeep Patel, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}