added opening animation
This commit is contained in:
parent
f2895a3b0e
commit
e2e7e90e01
3 changed files with 107 additions and 73 deletions
20
burger.js
20
burger.js
|
@ -3,21 +3,37 @@
|
||||||
|
|
||||||
function toggleMenu() {
|
function toggleMenu() {
|
||||||
const menu = document.querySelector(".menu");
|
const menu = document.querySelector(".menu");
|
||||||
|
|
||||||
|
// Toggle the 'active' class to show/hide the menu
|
||||||
menu.classList.toggle("active");
|
menu.classList.toggle("active");
|
||||||
|
|
||||||
// Add event listener to close menu when clicking anywhere on the document
|
// Apply animations based on the menu's visibility
|
||||||
if (menu.classList.contains("active")) {
|
if (menu.classList.contains("active")) {
|
||||||
|
menu.style.animation = "slideIn 0.3s forwards";
|
||||||
document.addEventListener("click", closeMenu);
|
document.addEventListener("click", closeMenu);
|
||||||
} else {
|
} else {
|
||||||
|
menu.style.animation = "slideOut 0.3s forwards";
|
||||||
|
// Remove the event listener to close the menu
|
||||||
document.removeEventListener("click", closeMenu);
|
document.removeEventListener("click", closeMenu);
|
||||||
|
// Reset animation after it's completed
|
||||||
|
menu.addEventListener("animationend", () => {
|
||||||
|
menu.style.animation = "";
|
||||||
|
}, { once: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeMenu(event) {
|
function closeMenu(event) {
|
||||||
const menu = document.querySelector(".menu");
|
const menu = document.querySelector(".menu");
|
||||||
|
// Check if the click is outside the menu and not on the burger icon
|
||||||
if (!menu.contains(event.target) && !event.target.classList.contains("burger-menu")) {
|
if (!menu.contains(event.target) && !event.target.classList.contains("burger-menu")) {
|
||||||
menu.classList.remove("active");
|
menu.style.animation = "slideOut 0.3s forwards";
|
||||||
|
// Remove the event listener to close the menu
|
||||||
document.removeEventListener("click", closeMenu);
|
document.removeEventListener("click", closeMenu);
|
||||||
|
// Reset animation after it's completed
|
||||||
|
menu.addEventListener("animationend", () => {
|
||||||
|
menu.classList.remove("active");
|
||||||
|
menu.style.animation = "";
|
||||||
|
}, { once: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
140
styles.css
140
styles.css
|
@ -4,7 +4,7 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-family: "Roboto", Arial, sans-serif;
|
font-family: "Roboto", Arial, sans-serif;
|
||||||
transition: all 2s ease; /* Smooth transitions */
|
transition: 3s; /* Smooth transitions */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Body styles */
|
/* Body styles */
|
||||||
|
@ -21,13 +21,14 @@ body {
|
||||||
/* Header styles */
|
/* Header styles */
|
||||||
header {
|
header {
|
||||||
background-color: #2c3e50;
|
background-color: #2c3e50;
|
||||||
padding: 15px 0; /* Adjusted padding */
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 1000;
|
|
||||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
||||||
|
padding: 0; /* Further reduce the padding */
|
||||||
|
height: auto;
|
||||||
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-content {
|
.header-content {
|
||||||
|
@ -36,13 +37,29 @@ header {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
max-width: 1200px;
|
max-width: 1200px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
padding: 0 20px; /* Original padding */
|
padding: 0 20px; /* Original padding */
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
header li {
|
||||||
|
margin: 0;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
header a {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px 0;
|
||||||
|
text-align: center; /* Center align the menu items */
|
||||||
}
|
}
|
||||||
|
|
||||||
.project-name {
|
.project-name {
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-size: 1.5em; /* Updated font size */
|
font-size: 1.5em; /* Updated font size */
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.burger-menu {
|
.burger-menu {
|
||||||
|
@ -51,16 +68,52 @@ header {
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
font-size: 1.5em; /* Updated font size */
|
font-size: 1.5em; /* Updated font size */
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: none;
|
display: block;
|
||||||
|
padding: 0;
|
||||||
|
z-index: 9999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu {
|
.menu {
|
||||||
|
display: none;
|
||||||
|
flex-direction: column;
|
||||||
|
background-color: #2c3e50;
|
||||||
|
position: absolute;
|
||||||
|
top: 100%;
|
||||||
|
left: 0;
|
||||||
|
width: 100%; /* Full width of the header */
|
||||||
|
z-index: 999;
|
||||||
|
padding: 0;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
|
justify-content: center; /* Center items vertically */
|
||||||
|
text-align: center; /* Center items horizontally */
|
||||||
|
animation: slideOut 0.3s ease forwards; /* Initial animation state */
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu.active {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
animation: slideIn 0.3s ease forwards; /* Show animation */
|
||||||
align-items: center;
|
}
|
||||||
flex-grow: 1;
|
|
||||||
margin: 0;
|
.menu.closed {
|
||||||
|
animation: slideOut 0.3s ease forwards; /* Hide animation */
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slideIn {
|
||||||
|
from {
|
||||||
|
transform: translateY(-100%);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slideOut {
|
||||||
|
from {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: translateY(-100%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header li {
|
header li {
|
||||||
|
@ -73,6 +126,7 @@ header a {
|
||||||
padding: 8px; /* Smaller padding */
|
padding: 8px; /* Smaller padding */
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
transition: background-color 0.3s ease;
|
transition: background-color 0.3s ease;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
header a:hover {
|
header a:hover {
|
||||||
|
@ -81,7 +135,6 @@ header a:hover {
|
||||||
|
|
||||||
/* Article styles */
|
/* Article styles */
|
||||||
article {
|
article {
|
||||||
margin-top: 8em;
|
|
||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
|
@ -90,6 +143,8 @@ article {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
margin-top: 140px; /* Increase margin-top for better readability */
|
||||||
|
padding-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
|
@ -138,12 +193,14 @@ nav {
|
||||||
}
|
}
|
||||||
|
|
||||||
.folder-list {
|
.folder-list {
|
||||||
|
justify-content: center;
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.folder-list-item {
|
.folder-list-item {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.folder-link {
|
.folder-link {
|
||||||
|
@ -165,60 +222,21 @@ nav {
|
||||||
transform: scale(0.98); /* Slight scale down on click */
|
transform: scale(0.98); /* Slight scale down on click */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mobile Styles */
|
/* Animation styles */
|
||||||
@media (max-width: 4000px) {
|
@keyframes slideIn {
|
||||||
.burger-menu {
|
from {
|
||||||
display: block;
|
transform: translateY(-100%);
|
||||||
padding: 0;
|
}
|
||||||
|
to {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu {
|
@keyframes slideOut {
|
||||||
display: none;
|
from {
|
||||||
flex-direction: column;
|
transform: translateY(0);
|
||||||
background-color: #2c3e50;
|
|
||||||
position: absolute;
|
|
||||||
top: 100%;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
z-index: 999;
|
|
||||||
padding: 0;
|
|
||||||
}
|
}
|
||||||
|
to {
|
||||||
.menu.active {
|
transform: translateY(-100%);
|
||||||
display: flex;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
header {
|
|
||||||
padding: 0; /* Further reduce the padding */
|
|
||||||
height: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-content {
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
padding: 0 20px; /* Original padding */
|
|
||||||
}
|
|
||||||
|
|
||||||
.project-name {
|
|
||||||
font-size: 1.5em; /* Updated font size */
|
|
||||||
}
|
|
||||||
|
|
||||||
header li {
|
|
||||||
margin: 0;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
header a {
|
|
||||||
width: 100%;
|
|
||||||
padding: 12px 0;
|
|
||||||
text-align: center; /* Center align the menu items */
|
|
||||||
}
|
|
||||||
|
|
||||||
article {
|
|
||||||
margin-top: 140px; /* Increase margin-top for better readability */
|
|
||||||
padding-top: 20px;
|
|
||||||
margin-bottom: 20px; /* Adjust margin-bottom for consistency */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue