SlideServe
Menu
Préférences
© SlideServe · v2026

Chapter 24

jetta avatar
9 diapositives · 254 Views · Jul 30, 2014

Chapter 24. Performing CSS Transitions and Animations. Learning Objectives. How to use CSS transitions to specify an HTML element’s ending state, as defined by CSS property values

Chapter 24 - slide 1
01 / 9Chapter 24
1 / 17

Télécharger la présentation

Chapter 24
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Chapter 24 Performing CSS Transitions and Animations

  2. Learning Objectives • How to use CSS transitions to specify an HTML element’s ending state, as defined by CSS property values • How to trigger a CSS transition by changing the value of one of the properties the transition uses so that the browser will apply the transition • How to create a CSS animation using a collection of CSS transitions

  3. Starting with transitions • To create a CSS transition, specify ending state property values for an HTML element, such as color, opacity, or location. When you change one of the specified property values, you trigger the browser’s application of the transition.

  4. Changing image opacity • <!DOCTYPE html><html><head><style>img { -moz-transition: opacity 5s;-ms-transition: opacity 5s;-o-transistion: opacity 5s;-webkit-transition: opacity 5s;transition: opacity 5s;}</style><script>function ShowImage(){document.getElementById("wine").style.opacity = 1;}</script></head><body><img id="wine" style="opacity:0" src="http://www.websitedevelopmentbook.com/chapter23/wine.jpg"><br/><button onclick="ShowImage()">Click Here</button></body></html>

  5. Extending a box • <!DOCTYPE html><html><head><style>div { -moz-transition: width 5s, background-color 5s; -ms-transition: width 5s, background-color 5s; -o-transition: width 5s, background-color 5s; -webkit-transition width 5s, background-color 5s; • transition: width 5s, background-color 5s; }</style><script>function SlideBox(){document.getElementById('box').style.width = '500px';document.getElementById('box').style.backgroundColor = '#FF0000';}</script></head><body><div id="box" style="background-color:blue; position:relative; width:200px; height:200px;"></div><br/><button onclick="SlideBox();">Click Here</button></body></html>

  6. Using a timer to slide a box • <!DOCTYPE html><html><head><style>div { -moz-transition: width 5s, background-color 5s; -ms-transition: width 5s, background-color 5s; -o-transition: width 5s, background-color 5s; -webkit-transition width 5s, background-color 5s; transition: width 5s, background-color 5s; }</style><script>var direction = "right";function CloseBox(){document.getElementById('box').style.width = '200px';document.getElementById('box').style.backgroundColor = '#0000FF';setTimeout(function () { SlideBox(); }, 6000);}function SlideBox(){document.getElementById('box').style.width = '500px';document.getElementById('box').style.backgroundColor = '#FF0000';setTimeout(function () { CloseBox(); }, 6000);}</script></head><body><div id="box" style="background-color:blue; position:relative; width:200px; height:200px;"></div><br/><button onclick="SlideBox();">Click Here</button></body></html>

  7. Scaling a welcome message • <!DOCTYPE html><html><head><style>p { -moz-transition: font-size 8s; -ms-transition: font-size 8s; -o-transition: font-size 8s; -webkit-transition font-size 8s; transition: font-size 8s; }</style><script>function GrowFont(){document.getElementById('welcome').style.fontSize = '500%'; • }</script></head><body onload="GrowFont()"><div><p id="welcome" style="text-align:center;">Welcome!</p></div></body></html>

  8. Real world: w3c Css transitions

  9. summary • Throughout this book, you have performed text- and graphics-based animations using JavaScript, JQuery, and the HTML 5 canvas. • In this chapter, you learned how to use CSS transitions to specify an HTML element’s ending properties. • When you trigger a transition, the browser changes the element from its current state to your specified ending state. • This chapter also introduced CSS animations, which are essentially a collection of transitions developers call “keyframes.” • The browser plays a major role in the CSS transition process. Before you use transitions or animations within your webpages, make sure you have the browser support you need.