React Collapsable Navbar
How do I make an react collapsable navbar?
Collapsable navbar templates such as Bootstrap exist but often include a lot of extra stuff that you have to remove if you just want something simpler. This is that something simpler. I wanted to build something extremely simple and easy to modify so that it can be used in anything that just requires a simple navbar that collapses for a mobile screen.. What is a react collapsable navbar? How do you make a react collapsable navbar? This script and codes were developed by Dan on 07 January 2023, Saturday.
React Collapsable Navbar - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>React Collapsable Navbar</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <navbar></navbar> <script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
React Collapsable Navbar - Script Codes CSS Codes
nav { background-color: #00F; overflow: hidden; padding: 1em; border-bottom: 1px solid #000;
}
nav a { color: #FFF;
}
nav a:visited { color: #FFF;
}
nav .navWide { display: none; margin: 0 auto;
}
nav .navWide .wideDiv { text-align: center;
}
nav .navWide .wideDiv a { text-decoration: none; display: inline-block; padding: 0 2em;
}
nav .navNarrow i { float: left; cursor: pointer; color: #FFF;
}
nav .navNarrow .narrowLinks { display: none;
}
nav .navNarrow .narrowLinks a { text-decoration: none; display: block; float: left; clear: left; padding: 0.5em 0;
}
@media (min-width: 480px) { nav .navWide { display: block; } nav .navNarrow { display: none; }
}
React Collapsable Navbar - Script Codes JS Codes
"use strict";
var NavComponent = React.createClass({ displayName: "NavComponent", render: function render() { return React.createElement( "nav", null, React.createElement( "div", { className: "navWide" }, React.createElement( "div", { className: "wideDiv" }, React.createElement( "a", { href: "#" }, "Link 1" ), React.createElement( "a", { href: "#" }, "Link 2" ), React.createElement( "a", { href: "#" }, "Link 3" ) ) ), React.createElement( "div", { className: "navNarrow" }, React.createElement("i", { className: "fa fa-bars fa-2x", onClick: this.burgerToggle }), React.createElement( "div", { className: "narrowLinks" }, React.createElement( "a", { href: "#", onClick: this.burgerToggle }, "Link 1" ), React.createElement( "a", { href: "#", onClick: this.burgerToggle }, "Link 2" ), React.createElement( "a", { href: "#", onClick: this.burgerToggle }, "Link 3" ) ) ) ); }, burgerToggle: function burgerToggle() { var linksEl = document.querySelector('.narrowLinks'); if (linksEl.style.display === 'block') { linksEl.style.display = 'none'; } else { linksEl.style.display = 'block'; } }
});
ReactDOM.render(React.createElement(NavComponent, null), document.querySelector('navbar'));
Developer | Dan |
Username | danbuda |
Uploaded | January 07, 2023 |
Rating | 3.5 |
Size | 3,531 Kb |
Views | 4,048 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Simple React Router | 2,707 Kb |
Sticky Footer | 1,655 Kb |
Alphabetizing Lists with JavaScript | 2,719 Kb |
Simple Collapsable Navbar | 2,667 Kb |
Just Some Buttons | 1,568 Kb |
Sass Mixin Example | 1,944 Kb |
JavaScript Alphabetize Function | 2,596 Kb |
My First Mixin | 2,017 Kb |
Sorting Items While Ignoring Articles | 3,002 Kb |
React Routing with this.props.children | 2,725 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Tooltip in table | Roine | 3,713 Kb |
APortfolio | Skybutterfly | 5,174 Kb |
Draggable directive | YahyaKacem | 2,277 Kb |
Sexy Social Buttons | Ipiyale | 2,226 Kb |
CSS Flip Animation | Bbodine1 | 2,525 Kb |
Hovers with popups | Zacharyolson | 2,380 Kb |
Tab Menus | Zephyr | 3,180 Kb |
Scoreboard.js basic usage | Tbleckert | 1,733 Kb |
Importable Clearfix | Corysimmons | 1,411 Kb |
Calendar | Miroot | 2,033 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!