{"id":3062,"date":"2017-05-18T14:19:01","date_gmt":"2017-05-18T19:19:01","guid":{"rendered":"http:\/\/cssnewbie.com\/?p=2288"},"modified":"2017-05-18T14:19:01","modified_gmt":"2017-05-18T19:19:01","slug":"how-to-use-css3s-transition-property","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/how-to-use-css3s-transition-property\/","title":{"rendered":"How to Use CSS3&#8217;s Transition Property"},"content":{"rendered":"<p>Don&#8217;t be intimidated by CSS transitions! They might seem complicated if you know nothing about them, but really, they&#8217;re pretty straightforward and easy to implement. A transition animation occurs when a value of any property of an element is triggered to change &#8212; often something like this happens when you&#8217;ve implemented a hover effect. Let&#8217;s say you have a button that you want to make more transparent when it&#8217;s hovered upon, but you want there to be a gradual transition that occurs so the opacity change isn&#8217;t jarring or rigid. That&#8217;s where transition code comes in. To execute a smooth, beautiful CSS transition, all you really need is a few lines of simple CSS code.<\/p>\n<pre>The transition property is actually shorthand for the four transition related CSS properties: transition-property, transition-duration, transition-timing-function, and transition-delay. The syntax of the shorthand is as follows:\n\nselector{\n\u00a0 \u00a0transition: [transition-property] [transition-duration] [transition-timing-function] [transition-delay]\n}<\/pre>\n<p>It&#8217;s super important that you remember to include the transition-duration, or the duration time will be defaulted to 0s, and the transition effect won&#8217;t occur. Also &#8212; be sure to use s (seconds) to quantify duration times.<\/p>\n<p>Let&#8217;s see an example of this in action. For the purposes of this example, let&#8217;s say we want to add a transition effect to the changing of the height of an div element upon hover. Here&#8217;s the code that we would need to achieve this effect:<\/p>\n<pre>div{\n\u00a0 \u00a0height: 100px;\n\u00a0 \u00a0-webkit-transition: height 3s;\n}<\/pre>\n<pre>div:hover{\n\u00a0 \u00a0height: 200px;\n}<\/pre>\n<p>As you can see, we only included the transition-property and transition-duration values in the example. That&#8217;s because the other two properties are being left to their default values. If you don&#8217;t define any of the property values in the shorthand, they&#8217;ll just resort to their default. Also, be sure to use vendor prefixes with this property, as it isn&#8217;t supported by every browser.<\/p>\n<p>When using the transition property, don&#8217;t forget to define the CSS property that the transition is going to apply to &#8212; if the div:hover property with the change of height for the element didn&#8217;t exist, then there would be no transition effect. If there&#8217;s more than one property that&#8217;s going to change with your transition, you can use the transition-property &#8220;all&#8221; \u00a0in your transition shorthand to ensure that all of the desired transitions occur.<\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Don&#8217;t be intimidated by CSS transitions! They might seem complicated if you know nothing about them, but really, they&#8217;re pretty straightforward and easy to implement. A transition animation occurs when a value of any property of an element is triggered [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/how-to-use-css3s-transition-property\/\" title=\"Click to read 'How to Use CSS3&#8217;s Transition Property'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[174,1],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3062"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=3062"}],"version-history":[{"count":0,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3062\/revisions"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=3062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=3062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=3062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}