JSFiddle - React, Tailwind, and code Playground
by c2webdev
HTML
<title>Responsive Navigation Demo</title>
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
$(function() {
var pull = $('#pull');
menu = $('nav ul');
menuHeight = menu.height();
$(pull).on('click', function(e) {
e.preventDefault();
menu.slideToggle();
});
$(window).resize(function(){
var w = $(window).width();
if(w > 320 && menu.is(':hidden')) {
menu.removeAttr('style');
}
});
});
</script>
<body>
<div id="mob-header"></div>
<nav class="clearfix">
<a href="#" id="pull">Home |<div id="our-charity" onclick="window.location=''">Link1</div> </a>
<ul class="clearfix">
<li><a href="#">Item 1</a></li>
<li><a href="#">Item 2</a></li>
<li><a href="#">Item 3</a></li>
<li><a href="#">Item 4</a></li>
<li><a href="#">Item 5</a></li>
<li><a href="#">Item 6</a></li>
<li><a href="#">Item 7</a></li>
<li><a href="#">Item 8</a></li>
</ul>
</nav>
</body>
</html>
CSS
/**/
#mob-header{background:url('image.png') right no-repeat #0098DB; height:3.9em; border:1px solid #000;}
#our-charity { width:6em; height:auto; display:inline; padding:0 0 0 0.5em;}
/* Clearfix */
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
background: #e7f7fe;
}
/* Basic Styles */
body {}
nav {
height: 40px;
width: 100%;
background: #e7f7fe;
font-size: 11pt;
font-family: 'PT Sans', Arial, sans-serif;
font-weight: bold;
position: relative;
}
nav ul {
padding: 0;
margin: 0 auto;
width: 100%;
height: 40px;
}
nav li {
display: inline;
float: left;
}
nav a {
display: inline-block;
width: 12em;
text-decoration: none;
line-height: 40px;
color:#0098DB;
}
nav li a {
border: 1px solid #0098DB;
}
nav li:last-child a {
border-right:1px solid #0098DB;
}
nav a:hover, nav a:active {
background-color: #0098DB;
color:#e7f7fe;
}
nav a#pull {
display: none;
}
/*Styles for screen 515px and lower*/
@media only screen and (max-width : 140em) {
nav {
border-bottom: 0;
}
nav ul {
display: none;
height: auto;
}
nav a#pull {
display: block;
background-color: #0098DB;
width: 100%;
position: relative;
color:#fff;
}
nav a#pull:after {
content:"";
background: url('nav-icon.png') no-repeat;
width: 30px;
height: 20px;
display: inline-block;
float:left;
margin:0.7em 0 0 0.2em;
}
}
/*Smartphone*/
@media only screen and (max-width : 320px) {
nav li {
display: block;
float: none;
width: 100%;
}
nav li a {
border-bottom: 1px solid #576979;
}
}