Fab button that expands to a Tab menu
Created
October 16, 2019 11:43
-
-
Save vjsolanki/963e200459ac786e1c9832c27ce5df2c to your computer and use it in GitHub Desktop.
Fab to tab
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 class="wrap"> | |
| <h1>Fab to tab</h1> | |
| <p>Inspired by <a href="https://dribbble.com/shots/2366718-Fab-Animation" target="_blank">Georg Bednorz</a></p> | |
| </div> | |
| <div class="menu-button"> | |
| <div class="minified"><i class="mdi mdi-arrow-expand"></i></div> | |
| <div class="content"> | |
| <span class="tab active"><i class="mdi mdi-clippy"></i></span> | |
| <span class="tab"><i class="mdi mdi-android"></i></span> | |
| <span class="tab"><i class="mdi mdi-trophy-outline"></i></span> | |
| <span class="tab"><i class="mdi mdi-emoticon-devil"></i></span> | |
| <span class="tab close"><i class="mdi mdi-close"></i></span> | |
| </div> | |
| </div> | |
| <footer></footer> |
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
| $('.menu-button').on('click', function() { | |
| $(this).addClass('expanded'); | |
| $('.tab').removeClass('active'); | |
| $(this).find('.tab').first().addClass('active'); | |
| }); | |
| $('.tab').on('click', function(e) { | |
| e.stopPropagation(); | |
| $('.tab').removeClass('active'); | |
| $(this).addClass('active'); | |
| }); | |
| $('.close').on('click', function(e) { | |
| e.stopPropagation(); | |
| e.preventDefault(); | |
| $(this).closest('.menu-button').removeClass('expanded'); | |
| }); |
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 url(https://fonts.googleapis.com/css?family=Roboto:400,300) | |
| @import url(https://cdn.materialdesignicons.com/1.3.41/css/materialdesignicons.min.css) | |
| $speed: 0.5 | |
| .wrap | |
| margin: 0 auto | |
| width: 200px | |
| text-align: center | |
| color: white | |
| text-shadow: 1px 1px 5px rgba(0,0,0,.3) | |
| body, html | |
| padding: 0 | |
| margin: 0 | |
| background: #455A64 | |
| box-sizing: border-box | |
| font-family: 'Roboto', sans-serif | |
| padding-bottom: -50px | |
| *, *:before, *:after | |
| box-sizing: inherit | |
| a | |
| text-decoration: none | |
| color: white | |
| border-bottom: 1px dashed rgba(255,255,255,.5) | |
| &:hover | |
| text-shadow: 1px 1px 5px #000000 | |
| i | |
| color: #73BDAD | |
| .menu-button | |
| width: 50px | |
| height: 50px | |
| border-radius: 50px | |
| background: white | |
| position: fixed | |
| bottom: 65px | |
| right: 15px | |
| box-shadow: 0 2px 5px 0 rgba(0,0,0,0.25) | |
| cursor: pointer | |
| color: white | |
| transition: all $speed*1s cubic-bezier(.42, 0, 0, 1) | |
| text-align: center | |
| line-height: 53px | |
| font-size: 25px | |
| &:hover | |
| background: #ddd | |
| box-shadow: 0 5px 15px 0 rgba(0,0,0,0.4) | |
| .content | |
| width: 100% | |
| visibility: hidden | |
| opacity: 0 | |
| transition: all 0 ease | |
| span | |
| border-top: 5px solid transparent | |
| flex-grow: 5 | |
| height: 65px | |
| line-height: 60px | |
| &.active | |
| border-top: 5px solid #73BDAD | |
| &.close | |
| flex-grow: 1 | |
| i | |
| color: #FF5252 | |
| .minified | |
| display: block | |
| &.expanded | |
| width: 100vw | |
| height: 65px | |
| right: 0 | |
| bottom: 50px | |
| border-radius: 0 | |
| background: white | |
| .minified | |
| display: none | |
| .content | |
| display: flex | |
| visibility: visible | |
| opacity: 1 | |
| transition: all 1s ease | |
| footer | |
| height: 50px | |
| width: 100% | |
| bottom: 0 | |
| position: fixed | |
| background: black | |
| @keyframes expand | |
| 0% | |
| border-radius: 50px | |
| 50% | |
| border-radius: 5px | |
| 100% | |
| border-radius: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment