├── README.md ├── css └── main.css ├── js └── main.js └── index.html /README.md: -------------------------------------------------------------------------------- 1 | # Bootstrap-Bottom-Nav 2 | A simple one-page website that utilizes JavaScript and Bootstrap4 to make an Android-like navbar 3 | 4 | [Try it here](https://ajhenry.github.io/Bootstrap4-Bottom-Navbar/) 5 | 6 | # Mobile Only 7 | This is made for mobile only formats at the moment 8 | -------------------------------------------------------------------------------- /css/main.css: -------------------------------------------------------------------------------- 1 | html { 2 | position: relative; 3 | min-height: 100%; 4 | } 5 | 6 | body { 7 | margin-bottom: 80px; 8 | margin-top: 60px; 9 | } 10 | 11 | .footer { 12 | position:fixed; 13 | bottom: 0; 14 | width: 100%; 15 | height: 60px; 16 | background-color: #f5f5f5; 17 | 18 | border-top: 1px solid transparent; 19 | box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2); 20 | } 21 | 22 | .navbar{ 23 | border-top: 1px solid transparent; 24 | box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2); 25 | } 26 | 27 | .group-container{ 28 | padding:0; 29 | height:100%; 30 | } 31 | 32 | .selectors, .block{ 33 | height:100%; 34 | width:100%; 35 | } 36 | 37 | .selectors button{ 38 | border: 0; 39 | border-radius: 0; 40 | background-color: #f8f9fa !important; 41 | width:25%; 42 | margin-left: 0; 43 | } 44 | 45 | .selectors button:active{ 46 | border:0; 47 | } 48 | 49 | .selectors button:focus{ 50 | border:0; 51 | outline: 0; 52 | box-shadow: 0 0 0 0px; 53 | } 54 | 55 | .active, .selector-holder{ 56 | display: flex; 57 | flex-direction: column; 58 | } 59 | 60 | .inactive{ 61 | display: none; 62 | } 63 | 64 | .selector-holder span{ 65 | font-size: 0.8rem; 66 | } 67 | 68 | /* Colors of the buttons*/ 69 | .button-active, .selectors button:hover, .selectors button:active, .selectors button:focus{ 70 | color: #ff0000; 71 | } 72 | 73 | .button-inactive{ 74 | color: #000; 75 | } 76 | -------------------------------------------------------------------------------- /js/main.js: -------------------------------------------------------------------------------- 1 | //Global variable for starting page 2 | var currentPageId = "page-home"; 3 | var currentSelectorId = "home"; 4 | 5 | //Function for getting the button ids 6 | function getButtons(){ 7 | //List of button ids 8 | var list = ["home", "feed", "create", "account"]; 9 | return list; 10 | } 11 | 12 | //Make sure the window is loaded before we add listeners 13 | window.onload = function(){ 14 | var pageIdList = getButtons(); 15 | //Add an event listener to each button 16 | pageIdList.forEach(function(page){ 17 | document.getElementById(page).addEventListener("click", changePage, false); 18 | }); 19 | } 20 | 21 | function changePage(){ 22 | var currentSelector = document.getElementById(currentSelectorId); 23 | var currentPage = document.getElementById(currentPageId); 24 | var pageId = "page-"+this.id; 25 | var page = document.getElementById(pageId); 26 | var pageSelector = document.getElementById(this.id); 27 | 28 | if(page.classList.contains("active")){ 29 | return; 30 | } 31 | 32 | currentSelector.classList.remove("button-active"); 33 | currentSelector.classList.add("button-inactive"); 34 | currentPage.classList.remove("active"); 35 | currentPage.classList.add("inactive"); 36 | 37 | pageSelector.classList.remove("button-inactive"); 38 | pageSelector.classList.add("button-active"); 39 | 40 | page.classList.remove("inactive"); 41 | page.classList.add("active"); 42 | 43 | //Need to reset the scroll 44 | window.scrollTo(0,0); 45 | 46 | currentSelectorId = this.id; 47 | currentPageId = pageId; 48 | } -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 |