A Pen by shed_codepen on CodePen.
-
-
Save CodeMyUI/8b3505fe4b070f3093df to your computer and use it in GitHub Desktop.
animation - flip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="app"> | |
| <p class="m-flip js-flip" style="font-size: 60px; font-family:Abel;"> | |
| <span class="m-flip_item">ABCDEFGHIJKLMNOPQRSTUVWXYZ</span> | |
| <span class="m-flip_item">ABCDEFGHIJKLMNOPQRSTUVWXYZ</span> | |
| </p> | |
| <p class="m-flip js-flip" style="font-size: 30px; font-family:'Permanent Marker', cursive;"> | |
| <span class="m-flip_item">ABCDEFGHIJKL<br>MNOPQRSTUVWXYZ</span> | |
| <span class="m-flip_item">あいうえおかきくけこさし<br>すせそたちつてとなにぬねのはひふへほ</span> | |
| </p> | |
| <p class="m-flip js-flip" style="font-size: 10px;"> | |
| <span class="m-flip_item">あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほ</span> | |
| <span class="m-flip_item">ABCDEFGHIJKLMNOPQRSTUVWXYZ</span> | |
| </p> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function($){ | |
| $.fn.flip = function(options){ | |
| var options = $.extend({ | |
| targetClass: '.m-flip_item' | |
| }, options); | |
| return this.each(function(){ | |
| console.log(this); | |
| var $this = $(this), | |
| $target = $this.find(options.targetClass); | |
| $this | |
| .on({ | |
| 'init.flip': function(){ | |
| var targetFirst_height = $target.eq(0).height(); | |
| $this | |
| .data('height', targetFirst_height) | |
| .css({ height: targetFirst_height }); | |
| }, | |
| 'mouseenter.flip': function(){ | |
| $target.css({ top: -$this.data('height') + 'px' }); | |
| }, | |
| 'mouseleave.flip': function(){ | |
| $target.css({ top: 0 + 'px' }); | |
| } | |
| }) | |
| .trigger('init.flip'); | |
| }); | |
| }; | |
| }(jQuery)); | |
| $(function(){ | |
| $('.js-flip').flip(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* @IMPORT FONTS */ | |
| @import url(https://fonts.googleapis.com/css?family=Abel); | |
| @import url(https://fonts.googleapis.com/css?family=Permanent+Marker); | |
| /* BASE */ | |
| body{ | |
| background-color: #000; | |
| color: #fff; | |
| font-family: sans-serif; | |
| line-height: 1; | |
| font-smoothing: antialiased; | |
| } | |
| #app{ | |
| width: 80%; | |
| margin: 0 auto; | |
| padding: 5% 0 0; | |
| } | |
| /** | |
| * ANIMATION - FLIP | |
| */ | |
| .m-flip{ | |
| overflow: hidden; | |
| cursor: pointer; | |
| } | |
| .m-flip_item{ | |
| display: block; | |
| position: relative; | |
| top: 0; | |
| transition: top .2s ease-out 0s; | |
| &:nth-child(1){ | |
| color: #666; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment