Last active
June 5, 2018 20:44
-
-
Save oliverbth05/b3657ffd103731afbc1f7c5535786c5c to your computer and use it in GitHub Desktop.
Mobile-Friendly Navigation (Vue)
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
| new Vue({ | |
| el:"#app", | |
| data: { | |
| navDrawer: false | |
| }, | |
| methods: { | |
| showDrawer: function(){ | |
| this.navDrawer = !this.navDrawer; | |
| }, | |
| dismissDrawer: function(){ | |
| this.navDrawer = false; | |
| } | |
| } | |
| }) |
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
| <head> | |
| <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous"> | |
| </head> | |
| <section id = "app"> | |
| <div class = "navbar"> | |
| <div class="logo"><i class="fas fa-chart-line"></i> Website</div> | |
| <div class="item">Data</div> | |
| <div class="item">Budget</div> | |
| <div class="item">Link 3</div> | |
| <div class="item">Link 4</div> | |
| <a class="btn-mobile" @click = "showDrawer"><i class="fas fa-bars"></i></a> | |
| </div> | |
| <template v-if = "navDrawer"> | |
| <div class = "drawer"> | |
| <div class = "drawer-items"> | |
| <a class = "drawer-item">Link</a> | |
| <a class = "drawer-item">Link</a> | |
| <a class = "drawer-item">Link</a> | |
| <a class = "drawer-item">Link</a> | |
| </div> | |
| <div class="drawer-filler"> | |
| <a @click = "dismissDrawer" class = "dismiss"></a> | |
| </div> | |
| </div> | |
| </template> | |
| </section> | |
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
| * { | |
| padding: 0; | |
| margin: 0; | |
| box-sizing: border-box; | |
| font-family: 'Open Sans', sans-serif; | |
| } | |
| .navbar{ | |
| width: 100%; | |
| background: crimson; | |
| margin: auto; | |
| color: white; | |
| display: flex; | |
| flex-direction: row; | |
| justify-content: center; | |
| align-items: center; | |
| transition: all .3s; | |
| } | |
| .item{ | |
| padding: 30px; | |
| cursor: pointer; | |
| margin: 0; | |
| } | |
| .item:hover{ | |
| transform: scale(1.1); | |
| transition: all .2s; | |
| } | |
| .btn-mobile{ | |
| visibility: hidden; | |
| } | |
| .logo{ | |
| padding: 20px; | |
| margin: 0; | |
| font-size: 20px; | |
| flex: 1; | |
| } | |
| .drawer{ | |
| height: 100%; | |
| width: 100%; | |
| position: absolute; | |
| } | |
| .drawer-items{ | |
| background: white; | |
| height: 100%; | |
| width: 40%; | |
| position: fixed; | |
| top: 0%; | |
| overflow:hidden; | |
| cursor: pointer; | |
| } | |
| .drawer-item{ | |
| display: block; | |
| text-align:center; | |
| padding: 20px; | |
| transition: all .5s; | |
| &:hover{ | |
| background: black; | |
| transition: all .3s; | |
| color: crimson; | |
| } | |
| } | |
| .drawer-filler{ | |
| background: rgba(50, 50, 50, 0.8); | |
| height: 100%; | |
| width: 60%; | |
| position: fixed; | |
| left: 40%; | |
| z-index: 2; | |
| top:0%; | |
| overflow: hidden; | |
| } | |
| .dismiss{ | |
| height: 100%; | |
| width: 100%; | |
| display: block; | |
| } | |
| /* Media Queries ----------------------------- */ | |
| @media only screen and (max-width: 900px) { | |
| .item{ | |
| display: none; | |
| } | |
| .logo{ | |
| text-align: center; | |
| font-size: 25px; | |
| } | |
| .btn-mobile{ | |
| visibility: visible; | |
| position: absolute; | |
| right: 5%; | |
| text-align:center; | |
| height: 45px; | |
| width: 45px; | |
| font-size: 20px; | |
| padding: 8px; | |
| font-weight: lighter; | |
| border-radius: 100px; | |
| transition: all .3s; | |
| } | |
| .btn-mobile:hover{ | |
| transform: scale(1.1); | |
| transition: all .4s; | |
| cursor: pointer; | |
| box-shadow: 0px 6px 15px 0px rgba(100,70,70,1); | |
| } | |
| .btn-mobile:active{ | |
| box-shadow: 0px 2px 8px 0px rgba(100,70,70,1); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment