responsive navbar
CSS
/*
Add a black background color to the top navigation */
.topnav {
background-color: #333;
overflow: hidden;
}
/*
Style the links inside the navigation bar */
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Change the color of links on hover */
.topnav a:hover {
background-color: #ddd;
color: black;
}
/* Add an active class to highlight the current page
*/
.topnav a.active {
background-color: #4CAF50;
color: white;
}
/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
display: none;
}
/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */
@media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
}
/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */
@media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive a.icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
} <!-- Load an icon library to show a hamburger menu (bars) on small screens -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="topnav"
id="myTopnav">
<a href="#home" class="active">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
<a href="javascript:void(0);"
class="icon" onclick="myFunction()">
<i
class="fa fa-bars"></i>
</a>
</div>
<script>
/* Toggle between adding and removing the "responsive" class to topnav when the user clicks on the icon */
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script <!-- Load an icon library to show a hamburger menu (bars) on small screens -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="topnav"
id="myTopnav">
<a href="#home" class="active">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
<a href="#about">About</a>
<a href="javascript:void(0);"
class="icon" onclick="myFunction()">
<i
class="fa fa-bars"></i>
</a>
</div>
Also in CSS:
- Title
- skeleton loader css
- Category
- CSS
- Title
- center h1 css
- Category
- CSS
- Title
- all child css
- Category
- CSS
- Title
- remove blue border on a input
- Category
- CSS
- Title
- css flex property
- Category
- CSS
- Title
- select second element of type css
- Category
- CSS
- Title
- javascript modify css
- Category
- CSS
- Title
- formatting checkbox css
- Category
- CSS
- Title
- make image background of div
- Category
- CSS
- Title
- skeleton css cdn
- Category
- CSS
- Title
- css padding vs margin
- Category
- CSS
- Title
- css focus border radius
- Category
- CSS
- Title
- how to bold in css
- Category
- CSS
- Title
- padding css shorthand
- Category
- CSS
- Title
- css center element on screen
- Category
- CSS
- Title
- jQuery remove a CSS style
- Category
- CSS
- Title
- css doesnt update
- Category
- CSS
- Title
- media querycss
- Category
- CSS
- Title
- css textarea limit
- Category
- CSS
- Title
- clip path css
- Category
- CSS
- Title
- css all uppercase to capitalize
- Category
- CSS
- Title
- css
- Category
- CSS
- Title
- justify content
- Category
- CSS
- Title
- css child selector
- Category
- CSS
- Title
- css overlapping divs
- Category
- CSS
- Title
- semantic ui react sidebar background
- Category
- CSS
- Title
- ms-clear event
- Category
- CSS
- Title
- css font families
- Category
- CSS
- Title
- media query
- Category
- CSS
- Title
- how to apply bg image in inline css
- Category
- CSS
- Title
- css php
- Category
- CSS
- Title
- html css position
- Category
- CSS
- Title
- css flex content right
- Category
- CSS
- Title
- css limit text length
- Category
- CSS
- Title
- center vertically and horizontally css
- Category
- CSS
- Title
- two classes css modules
- Category
- CSS
- Title
- not disabled css
- Category
- CSS
- Title
- css transition on hover
- Category
- CSS
- Title
- how to style input fields in css
- Category
- CSS
- Title
- table border css
- Category
- CSS
- Title
- css rotate 3d
- Category
- CSS
- Title
- vue import css
- Category
- CSS
- Title
- nice button css
- Category
- CSS
- Title
- round image css
- Category
- CSS
- Title
- html font white text with black border
- Category
- CSS
- Title
- css italic text
- Category
- CSS
- Title
- css flip svg
- Category
- CSS
- Title
- css display none but take up space
- Category
- CSS
- Title
- how to make a fullscreen button an an iframe
- Category
- CSS
- Title
- css circle border
- Category
- CSS
- Title
- how to print hello world with css
- Category
- CSS
- Title
- css overwriting styles
- Category
- CSS
- Title
- referance html id css
- Category
- CSS
- Title
- css gradient
- Category
- CSS
- Title
- html css make p div into two lines
- Category
- CSS
- Title
- how to add css to alt attribute text
- Category
- CSS
- Title
- remove bulltes css
- Category
- CSS
- Title
- como fazer elementos que scroll diferente
- Category
- CSS
- Title
- jquery remove css style
- Category
- CSS
- Title
- css first element
- Category
- CSS
- Title
- css efeito negativo fotos
- Category
- CSS
- Title
- css stylesheet template
- Category
- CSS
- Title
- css quitar el icono de lista
- Category
- CSS
- Title
- unselectable css property
- Category
- CSS
- Title
- pixel to inches
- Category
- CSS
- Title
- rotate image html
- Category
- CSS
- Title
- edge media query
- Category
- CSS
- Title
- how to move anything left in css
- Category
- CSS
- Title
- how to center text in css
- Category
- CSS
- Title
- css selectors w3schools
- Category
- CSS
- Title
- css font family
- Category
- CSS
- Title
- comment out css inline
- Category
- CSS
- Title
- css psedo class
- Category
- CSS
- Title
- overflow hidden in css
- Category
- CSS
- Title
- html5 input required length
- Category
- CSS
- Title
- how to center a div in css
- Category
- CSS
- Title
- how to stick a text to a div in css
- Category
- CSS
- Title
- line-height css
- Category
- CSS
- Title
- font weight css
- Category
- CSS
- Title
- letter spacing css
- Category
- CSS
- Title
- image position css
- Category
- CSS
- Title
- comment out css
- Category
- CSS
- Title
- line-height not working
- Category
- CSS
- Title
- css triangle generator
- Category
- CSS
- Title
- 1:1 image in css
- Category
- CSS
- Title
- how to center in absolute position
- Category
- CSS
- Title
- comments in css
- Category
- CSS
- Title
- display table css
- Category
- CSS
- Title
- css text justify
- Category
- CSS
- Title
- sketchup make
- Category
- CSS
- Title
- how do i move the numbers of an ordered list centered with css
- Category
- CSS
- Title
- css media query
- Category
- CSS
- Title
- css grid gap
- Category
- CSS
- Title
- css 2 <p> next to each other
- Category
- CSS
- Title
- css border opacity
- Category
- CSS
- Title
- html dim entire screen
- Category
- CSS
- Title
- breakline css
- Category
- CSS
- Title
- change color of css in js
- Category
- CSS
- Title
- font family css list
- Category
- CSS
- Title
- css transitions
- Category
- CSS