Line 1: | Line 1: | ||
− | < | + | <html lang="en"> |
+ | <head> | ||
+ | <title>Navbar CSS</title> | ||
+ | <meta charset="utf-8"> | ||
+ | <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
+ | <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | ||
+ | <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> | ||
+ | <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | ||
− | |||
− | |||
<style> | <style> | ||
+ | span.glyphicon-grain{ | ||
+ | font-size: 2em; | ||
+ | } | ||
+ | |||
+ | /************************************ Green Nav *****************************************************************************/ | ||
+ | .navbar-green { | ||
+ | background-color: #0f9347; | ||
+ | border-color: #0f9347; | ||
+ | top: 14px; | ||
+ | font-weight: bold; display: none; | ||
+ | } | ||
+ | .navbar-green .navbar-brand { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-green .navbar-brand:hover, | ||
+ | .navbar-green .navbar-brand:focus { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-green .navbar-text { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-green .navbar-nav > li > a { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-green .navbar-nav > li > a:hover, | ||
+ | .navbar-green .navbar-nav > li > a:focus { | ||
+ | color: #ffffff; | ||
+ | background-color: #0f9347; | ||
+ | } | ||
+ | .navbar-green .navbar-nav > .active > a, | ||
+ | .navbar-green .navbar-nav > .active > a:hover, | ||
+ | .navbar-green .navbar-nav > .active > a:focus { | ||
+ | color: #ffffff; | ||
+ | background-color: #0f9347; | ||
+ | } | ||
+ | .navbar-green .navbar-nav > .open > a, | ||
+ | .navbar-green .navbar-nav > .open > a:hover, | ||
+ | .navbar-green .navbar-nav > .open > a:focus { | ||
+ | color: #ffffff; | ||
+ | background-color: #0f9347; | ||
+ | } | ||
+ | .navbar-green .navbar-toggle { | ||
+ | border-color: #0f9347; | ||
+ | } | ||
+ | .navbar-green .navbar-toggle:hover, | ||
+ | .navbar-green .navbar-toggle:focus { | ||
+ | background-color: #0f9347; | ||
+ | } | ||
+ | .navbar-green .navbar-toggle .icon-bar { | ||
+ | background-color: #ffffff; | ||
+ | } | ||
+ | .navbar-green .navbar-collapse, | ||
+ | .navbar-green .navbar-form { | ||
+ | border-color: #0f9347; | ||
+ | } | ||
+ | .navbar-green .navbar-link { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-green .navbar-link:hover { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | |||
+ | @media (max-width: 767px) { | ||
+ | .navbar-green .navbar-nav .open .dropdown-menu > li > a { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-green .navbar-nav .open .dropdown-menu > li > a:hover, | ||
+ | .navbar-green .navbar-nav .open .dropdown-menu > li > a:focus { | ||
+ | color: #ffffff; | ||
+ | background-color: #8cc63f; | ||
+ | } | ||
+ | .navbar-green .navbar-nav .open .dropdown-menu > .active > a, | ||
+ | .navbar-green .navbar-nav .open .dropdown-menu > .active > a:hover, | ||
+ | .navbar-green .navbar-nav .open .dropdown-menu > .active > a:focus { | ||
+ | color: #ffffff; | ||
+ | background-color: #0f9347; | ||
+ | } | ||
+ | } | ||
− | |||
− | |||
− | |||
− | |||
+ | /************************************ Transparent Nav ***********************************************************************/ | ||
+ | .navbar-clear { | ||
+ | background-color: transparent; | ||
+ | border-color: transparent; | ||
+ | top: 14px; | ||
+ | font-weight: bold; | ||
} | } | ||
+ | .navbar-clear .navbar-brand { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-clear .navbar-brand:hover, | ||
+ | .navbar-clear .navbar-brand:focus { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-clear .navbar-text { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-clear .navbar-nav > li > a { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-clear .navbar-nav > li > a:hover, | ||
+ | .navbar-clear .navbar-nav > li > a:focus { | ||
+ | color: #ffffff; | ||
+ | background-color: transparent; | ||
+ | } | ||
+ | .navbar-clear .navbar-nav > .active > a, | ||
+ | .navbar-clear .navbar-nav > .active > a:hover, | ||
+ | .navbar-clear .navbar-nav > .active > a:focus { | ||
+ | color: #ffffff; | ||
+ | background-color: transparent; | ||
+ | } | ||
+ | .navbar-clear .navbar-nav > .open > a, | ||
+ | .navbar-clear .navbar-nav > .open > a:hover, | ||
+ | .navbar-clear .navbar-nav > .open > a:focus { | ||
+ | color: #ffffff; | ||
+ | background-color: transparent; | ||
+ | } | ||
+ | .navbar-clear .navbar-toggle { | ||
+ | border-color: transparent; | ||
+ | } | ||
+ | .navbar-clear .navbar-toggle:hover, | ||
+ | .navbar-clear .navbar-toggle:focus { | ||
+ | background-color: transparent; | ||
+ | } | ||
+ | .navbar-clear .navbar-toggle .icon-bar { | ||
+ | background-color: #ffffff; | ||
+ | } | ||
+ | .navbar-clear .navbar-collapse, | ||
+ | .navbar-clear .navbar-form { | ||
+ | border-color: #ffffff; | ||
+ | } | ||
+ | .navbar-clear .navbar-link { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-clear .navbar-link:hover { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | |||
+ | @media (max-width: 767px) { | ||
+ | .navbar-clear .navbar-nav .open .dropdown-menu > li > a { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-clear .navbar-nav .open .dropdown-menu > li > a:hover, | ||
+ | .navbar-clear .navbar-nav .open .dropdown-menu > li > a:focus { | ||
+ | color: #ffffff; | ||
+ | } | ||
+ | .navbar-clear .navbar-nav .open .dropdown-menu > .active > a, | ||
+ | .navbar-clear .navbar-nav .open .dropdown-menu > .active > a:hover, | ||
+ | .navbar-clear .navbar-nav .open .dropdown-menu > .active > a:focus { | ||
+ | color: #ffffff; | ||
+ | background-color: transparent; | ||
+ | } | ||
+ | } | ||
+ | |||
− | .dropdown { | + | /*submenu styling for the navbars*/ |
− | position: relative | + | .dropdown-submenu { |
− | + | position:relative; | |
− | + | ||
} | } | ||
+ | .dropdown-submenu>.dropdown-menu { | ||
+ | top:0; | ||
+ | left:100%; | ||
+ | margin-left:-1px; | ||
+ | width: 100%; | ||
− | + | -webkit-border-radius: 0px; | |
− | + | -moz-border-radius: 0px; | |
− | + | -o-border-radius: 0px; | |
− | + | border-radius: 0px; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
− | + | ||
− | display: block; | + | .dropdown-submenu>a:after { |
+ | display:block; | ||
+ | content:" "; | ||
+ | float:right; | ||
+ | width:0; | ||
+ | height:0; | ||
+ | border-color:transparent; | ||
+ | border-style:solid; | ||
+ | border-width:5px 0 5px 5px; | ||
+ | border-left-color:#cccccc; | ||
+ | margin-top:5px; | ||
+ | margin-right:-10px; | ||
} | } | ||
− | |||
+ | .dropdown-submenu.pull-left { | ||
+ | float:none !important; | ||
+ | } | ||
+ | .dropdown-submenu.pull-left>.dropdown-menu { | ||
+ | top: 0; | ||
+ | left:-100%; | ||
+ | margin-left:-1px; | ||
+ | width: 100%; | ||
+ | } | ||
+ | @media (max-width: 767px) { | ||
+ | .dropdown-submenu>.dropdown-menu {margin-left: 15px;} | ||
+ | .dropdown-submenu.pull-left>.dropdown-menu {margin-left: 15px;} | ||
+ | .navbar-green .open>a{ | ||
+ | background-color: #8cc63f; | ||
+ | } | ||
+ | } | ||
+ | </style> | ||
− | < | + | <script> |
− | + | //script to swap the clear navbar with the green nav | |
− | < | + | $(document).ready(function(){ |
− | + | var width = $(window).width(); | |
− | + | if(width < 768){ | |
+ | $(".navbar-clear").hide(); | ||
+ | $(".navbar-green").show(); | ||
+ | } | ||
− | + | //dropdown menu items open onclick instead of hover (mobile-friendly) | |
− | + | $('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event) { | |
− | + | event.preventDefault(); | |
− | + | event.stopPropagation(); | |
− | + | $(this).parent().siblings().removeClass('open'); | |
− | + | $(this).parent().toggleClass('open'); | |
− | + | }); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | }); | ||
− | + | $(window).on("scroll", function() {swapNavs()}); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | function swapNavs(){ | ||
+ | var width = $(window).width(); | ||
+ | if($(window).scrollTop() > 100) { | ||
+ | $(".navbar-clear").fadeOut(); | ||
+ | $(".navbar-green").fadeIn(); | ||
+ | } else if(width >= 768){ | ||
+ | $(".navbar-clear").fadeIn(); | ||
+ | $(".navbar-green").fadeOut(); | ||
+ | } | ||
+ | } | ||
+ | $(window).on("resize", function(){checkSize()}); | ||
− | + | function checkSize(){ | |
− | + | var width = $(window).width(); | |
− | + | if(width < 768){ | |
− | + | $(".navbar-clear").fadeOut(); | |
− | + | $(".navbar-green").fadeIn(); | |
− | + | } else if(width >= 768){ | |
− | </ | + | if($(window).scrollTop() >= 100){ |
+ | $(".navbar-clear").fadeOut(); | ||
+ | $(".navbar-green").fadeIn(); | ||
+ | }else if($(window).scrollTop() < 100) { | ||
+ | $(".navbar-clear").fadeIn(); | ||
+ | $(".navbar-green").fadeOut(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </script> | ||
+ | </head> | ||
+ | <header> | ||
+ | <nav class="navbar navbar-green navbar-fixed-top"> | ||
+ | <div class="container-fluid"> | ||
+ | <div class="navbar-header"> | ||
+ | <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | ||
+ | <span class="icon-bar"></span> | ||
+ | <span class="icon-bar"></span> | ||
+ | <span class="icon-bar"></span> | ||
+ | </button> | ||
+ | <a class="navbar-brand page-scroll" href="https://2016.igem.org/Team:British_Columbia"><span class="glyphicon glyphicon-grain"></span></a> | ||
+ | </div> | ||
+ | <div class="collapse navbar-collapse"> | ||
+ | <ul class="nav navbar-nav navbar-right"> | ||
+ | <li class="dropdown"> | ||
+ | <a href="#"class="dropdown-toggle" data-toggle="dropdown">Project | ||
+ | <span class="caret"></span></a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Description">Description</a></li> | ||
+ | <li class="dropdown-submenu"> | ||
+ | <a href="#" class="dropdown-toggle" data-toggle="dropdown">S-Layer</a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Project/S-Layer/Cellulases">Cellulases</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Project/S-Layer/Laccases">Laccases</a></li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Project/Bio-Pathways">Biosynthetic Pathways</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Project/Consortia">Consortia</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Proof">Proof</a></li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Model">Modelling</a></li> | ||
+ | <li class="dropdown"> | ||
+ | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Human Practices | ||
+ | <span class="caret"></span></a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British Columbia/HP/Gold">Introduction</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Human_Practices/Infographic">Infographic</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Human_Practices/Interview">Interview</a></li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | <li class="dropdown"> | ||
+ | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Team | ||
+ | <span class="caret"></span></a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Team/Bios">Bios</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Attributions">Attributions</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Team/Sponsors">Sponsors</a></li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Notebook">Notebook</a></li> | ||
+ | <li class="dropdown"> | ||
+ | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Achievements | ||
+ | <span class="caret"></span></a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Collaborations">Collaborations</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Achievements/Medal_Criteria">Medal Criteria</a></li> | ||
+ | <li class="dropdown-submenu pull-left"> | ||
+ | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Parts</a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Parts">Parts</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Basic_Part">Basic Part</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Composite_Part">Composite Part</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Part_Collection">Parts Collection</a></li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | </ul> | ||
+ | </div> | ||
+ | <!--collapse navbar-collapse --> | ||
+ | </div> | ||
+ | <!-- container-fluid --> | ||
+ | </nav> | ||
+ | <nav class="navbar navbar-clear navbar-fixed-top"> | ||
+ | <div class="container-fluid"> | ||
+ | <div class="navbar-header"> | ||
+ | <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | ||
+ | <span class="icon-bar"></span> | ||
+ | <span class="icon-bar"></span> | ||
+ | <span class="icon-bar"></span> | ||
+ | </button> | ||
+ | <a class="navbar-brand page-scroll" href="https://2016.igem.org/Team:British_Columbia"><span class="glyphicon glyphicon-grain"></span></a> | ||
+ | </div> | ||
+ | <div class="collapse navbar-collapse"> | ||
+ | <ul class="nav navbar-nav navbar-right"> | ||
+ | <li class="dropdown"> | ||
+ | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Project | ||
+ | <span class="caret"></span></a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Description">Description</a></li> | ||
+ | <li class="dropdown-submenu"> | ||
+ | <a href="#" class="dropdown-toggle" data-toggle="dropdown">S-Layer</a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Project/S-Layer/Cellulases">Cellulases</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Project/S-Layer/Laccases">Laccases</a></li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Project/Bio-Pathways">Biosynthetic Pathways</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Project/Consortia">Consortia</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Proof">Proof</a></li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Model">Modelling</a></li> | ||
+ | <li class="dropdown"> | ||
+ | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Human Practices | ||
+ | <span class="caret"></span></a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British Columbia/HP/Gold">Introduction</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Human_Practices/Infographic">Infographic</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Human_Practices/Interview">Interview</a></li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | <li class="dropdown"> | ||
+ | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Team | ||
+ | <span class="caret"></span></a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Team/Bios">Bios</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Attributions">Attributions</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Team/Sponsors">Sponsors</a></li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Notebook">Notebook</a></li> | ||
+ | <li class="dropdown"> | ||
+ | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Achievements | ||
+ | <span class="caret"></span></a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Collaborations">Collaborations</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Achievements/Medal_Criteria">Medal Criteria</a></li> | ||
+ | <li class="dropdown-submenu pull-left"> | ||
+ | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Parts</a> | ||
+ | <ul class="dropdown-menu"> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Parts">Parts</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Basic_Part">Basic Part</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Composite_Part">Composite Part</a></li> | ||
+ | <li><a href="https://2016.igem.org/Team:British_Columbia/Part_Collection">Parts Collection</a></li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | </ul> | ||
+ | </li> | ||
+ | </ul> | ||
+ | </div> | ||
+ | <!--collapse navbar-collapse --> | ||
+ | </div> | ||
+ | <!-- container-fluid --> | ||
+ | </nav> | ||
+ | </header> | ||
+ | </nav> | ||
+ | </div> | ||
+ | </body> | ||
</html> | </html> |
Revision as of 15:41, 2 August 2017