Replace menu with Sidebar TEST

This commit is contained in:
Fred Boniface 2022-10-10 20:51:35 +01:00
parent 34d47cfc4c
commit 405bf98f69
3 changed files with 57 additions and 134 deletions

View File

@ -50,121 +50,54 @@ footer {
left: 0;
}
/* NAVBAR STYLING BELOW */
/* Add a black background color to the top navigation */
.topnav {
background-color: #333;
overflow: hidden;
position: absolute;
width: 100%;
left: 0;
top: 0;
}
/* Style the links inside the navigation bar */
.topnav a {
float: left;
font-family: monospace;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Hide the link that should open and close the topnav on small screens */
.topnav .icon {
display: none;
}
/* Dropdown container - needed to position the dropdown content */
.dropdown {
float: left;
overflow: hidden;
}
/* Style the dropdown button to fit inside the topnav */
.dropdown .dropbtn {
font-size: 17px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: monospace;
margin: 0;
}
/* Style the dropdown content (hidden by default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
/* The sidebar menu */
.sidebar {
height: 100%;
width: 0; /* Hidden by default */
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: #111;
overflow-x: hidden; /* Disable horizontal scroll */
padding-top: 60px; /* Place content 60px from the top */
transition: 0.5s; /* 0.5 second transition effect to slide in the sidebar */
}
/* Style the links inside the dropdown */
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
/* The sidebar links */
.sidebar a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
text-align: left;
transition: 0.3s;
}
/* Add a dark background on topnav links and the dropdown button on hover */
.topnav a:hover, .dropdown:hover .dropbtn {
background-color: #555;
/* When you mouse over the navigation links, change their color */
.sidebar a:hover {
color: #f1f1f1;
}
/* Position and style the close button (top right corner) */
.sidebar .close {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
}
/* The button used to open the sidebar */
.open {
font-size: 20px;
cursor: pointer;
background-color: #111;
color: white;
padding: 10px 15px;
border: none;
}
/* Add a grey background to dropdown links on hover */
.dropdown-content a:hover {
background-color: #ddd;
color: black;
}
/* Show the dropdown menu when the user moves the mouse over the dropdown button */
.dropdown:hover .dropdown-content {
display: block;
}
/* 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), .dropdown .dropbtn {
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: absolute;
}
.topnav.responsive a.icon {
position: absolute;
right: 0;
top: 0;
}
.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
.topnav.responsive .dropdown {float: none;}
.dropdown-content {position: relative;}
.topnav.responsive .dropdown .dropbtn {
display: block;
width: 100%;
text-align: left;
}
.open:hover {
background-color: #444;
}

View File

@ -1,9 +1,7 @@
/* Toggle between adding and removing the "responsive" class to topnav when the user clicks on the icon */
function hamburger() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
function inflateSidebar() {
document.getElementById("sidebar").style.width = "250px";
}
function collapseSidebar() {
document.getElementById("sidebar").style.width = "0px";
}

View File

@ -1,19 +1,11 @@
<div class="topnav" id="myTopnav">
<a href="/">Home</a>
<a href="/gpg.php">GPG</a>
<div class="dropdown">
<button class="dropbtn">Downloads &#129142;</button>
<div class="dropdown-content">
<a href="/downloads/vcard.vcf">vCard</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Socials &#129142;</button>
<div class="dropdown-content">
<a href="https://fb.me/fred.boniface" target="_blank" rel="noreferrer noopener">Facebook</a>
<a href="https://500px.com/p/fredboniface" target="_blank" rel="noreferrer noopener">500px</a>
</div>
</div>
<a href="/projects.php">Projects</a>
<a href="javascript:void(0);" class="icon" onclick="hamburger()">&#9776;</a>
</div>
<div id="sidebar" class="sidebar">
<a href="javascript:void(0)" class="close" onclick="collapseSidebar()">&times;</a>
<a href="/">Home</a>
<a href="/gpg.php">GPG/PGP</a>
<a href="/projects.php">Projects</a>
<a href="/contact.php">Contact</a>
</div>
<div id="inflate">
<button class="open" onclick="inflateSidebar()">&#9776;</button>
</div>