728x90
๋ฐ์ํ
ํ๋ก๊ทธ๋๋ฐ ์ธ๊ณ๋ฅผ ํ๊ตฌํฉ์๋ค.
Spring Boot๋ฅผ ํ์ฉํ์ฌ ํ์ด์ง์ ์ฌ์ด๋ ๋ฐ๋ฅผ ๋ํ๋ผ ์ ์์ต๋๋ค.
์ค๋ฅธ์ชฝ์ ๋ฒ๊ฐ ๋ชจ์ ์ด๋ชจํฐ์ฝ์ ๋๋ฅด๋ฉด ์ฌ์ด๋๋ฐ๊ฐ ์ฌ๋ผ์ด๋ ํ์์ผ๋ก ์ด๋ฆฝ๋๋ค. ๋ก๊ทธ์ธ ์ , ํ์ ์์ฑ๋๋ ํญ๋ชฉ์ด ๋ค๋ฅด๋ฉฐ ํ์ ์์๊ฐ ์๋ ๋ชฉ๋ก์ ๋ง์ฐ์ค๋ฅผ ์ฌ๋ ธ์ ๋ ์ฌ์ด๋๋ฐ๊ฐ ํ๋ ๋ ์ด๋ฆฌ๋ฉด์ ํ์ ํญ๋ชฉ์ด ๋ํ๋ฉ๋๋ค. ์ฌ์ด๋ ๋ฐ์ ์์ง์์ ๋ฐ๋ผ ๋ฒ๊ฐ ๋ชจ์ ์ด๋ชจํฐ์ฝ๋ ํจ๊ป ์์ง์ ๋๋ค.
๊ตฌํ ํ๋ฉด
์์ฑ ์ฝ๋
nav.html
<!DOCTYPE html>
<html>
<head>
</head>
<style>
body {
z-index: 100;
}
.menubar a {
text-decoration: none;
}
.container {
background: none;
}
.button {
font-size: 50px;
position: relative;
right: 80px;
top: 0px;
width: 40px;
height: 40px;
z-index: 99;
transition: 0.8s ease;
background: none;
border: none;
}
/* .x {
align-items: center;
color: black;
margin: auto;
} */
.content {
padding: 100px 20px 0 40px;
position: relative;
width: 200%;
}
.nav-1 {
display: flex;
}
.nav-2 {
height: 80%;
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-evenly;
}
.home {
display: flex;
align-items: center;
height: 22px;
}
.my_account {
margin-top: -15px;
display: flex;
align-items: center;
height: 32px;
border-radius: 100%;
}
@font-face {
font-family: 'Cafe24Ssurround';
src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2105_2@1.0/Cafe24Ssurround.woff') format('woff');
font-weight: normal;
font-style: normal;
}
.word {
margin-left: 15px;
margin-top: -12px;
font-size: 25px;
font-family: 'Cafe24Ssurround';
color: black;
cursor: pointer;
}
@media (max-width: 768px) {
.sidebar {
right: -300px;
/* Move sidebar to the right */
}
.button {
right: 10px;
/* Move button to the right */
}
.content {
padding-right: 20px;
/* Adjust padding */
}
}
.menubar .submenu {
display: none;
}
.menubar {
position: relative;
}
.submenu {
display: none;
position: fixed;
top: 0;
right: 300px;
width: 300px;
height: 100%;
background-color: rgb(249, 227, 128);
padding-top: 11rem;
}
.sidebar {
background-color: rgb(237, 208, 77);
border-left: 2px solid rgb(237, 208, 77);
position: fixed;
top: 0;
bottom: 0;
right: 0;
transition: 0.4s ease;
color: #202020;
height: 100%;
z-index: 99;
}
</style>
<body>
<div class="container">
<div class="sidebar" style="width: 300px; height: 100%;">
<button class="button">โก
</button>
<div class="content">
<!-- <nav class="nav">
<div class="nav-1">
<div class="head_logo">
<a href="/">
<img class="logo_text" src="car.png" alt="๋ก๊ณ " />
</a>
</div>
</div> -->
<div class="nav-2">
<div class="menubar">
<a class="word" th:href="@{/}">ํ</a>
</div>
<div class="menubar">
<a class="word" th:href="@{/map}">์ถฉ์ ์ ์ฐพ๊ธฐ</a>
<!-- <div class="submenu">
<a class="word" th:href="@{/map}">์ง๋</a>
<a class="word" th:href="@{/map}">๋ชฉ๋ก ์ถ๊ฐ</a>
</div> -->
</div>
<div class="menubar">
<a class="word">๊ฒ์ํ</a>
<div class="submenu">
<a class="word" th:href="@{/board/list}">๊ณต์ง์ฌํญ</a>
<a class="word" th:href="@{/qna/list}">Q&A</a>
</div>
</div>
<div class="menubar">
<a class="word">์ ๋ณด๋ง๋น</a>
<div class="submenu">
<a class="word" th:href="@{/statistic/chargerStatus}">ํต๊ณ์ ๋ณด</a>
<a class="word" th:href="@{/statistic/ChargerExpense}">์๋น์ค์๋ด</a>
</div>
</div>
<div class="menubar">
<a class="word">๋ฏธ๋์ด</a>
<div class="submenu">
<a class="word" th:href="@{/media/news?searchText=์ ๊ธฐ์ฐจ}">์ ๊ธฐ์ฐจ ๋ด์ค</a>
<a class="word" th:href="@{/media/reels}">์ ๊ธฐ์ฐจ ์์</a>
<a class="word" th:href="@{/media/gamepage}">์ ๊ธฐ์ฐจ ๊ฒ์</a>
</div>
</div>
<div class="menubar">
<a class="word">๋ฉค๋ฒ์ญ</a>
<div class="submenu">
<a class="word" th:href="@{/exchange}">์ฝ์ธ๊ตํ</a>
<a class="word" th:href="@{/coupon}">์ฟ ํฐํจ</a>
<br>
<a class="word" th:href="@{/membership}">๊ฐ์
ํ๊ธฐ</a>
<a th:if="${session != null and session.user_info != null and session.has_membership}" class="word" th:href="@{/mymembership}">๋์ ๋ฉค๋ฒ์ญ</a>
</div>
</div>
</div>
<br>
<br>
<div th:if="${session.user_info == null}" class="menubar">
<a th:href="@{/signin}" class="word">๋ก๊ทธ์ธ</a>
<a th:href="@{/signup}" class="word">ํ์๊ฐ์
</a>
</div>
<div th:unless="${session.user_info == null}" class="menubar">
<span class="word">[[ ${session.user_info.name} + '๋ ๋ฐ๊ฐ์ต๋๋ค.' ]]</span>
<br>
<a class="word" th:href="@{/exchange}">๋์ ์ฐ๋ฆฌ๋ฆฟ: <span th:text="${userCoin}"></span>๊ฐ</a>
<br>
<a th:href="@{/mypage(email=${session.user_info.email})}" class="word">Mypage</a>
<br>
<!-- <a th:href="${session.user_info != null and session.user_info.role == 'ADMIN'}"></a> -->
<a th:if="${session != null and session.user_info != null and session.user_info.role == 'ADMIN'}" th:href="@{/admin}" class="word">
Admin
</a>
<br>
<a th:href="@{/signout}" class="word">๋ก๊ทธ์์</a>
</div>
</div>
</div>
</div>
</div>
</nav>
</div>
</div>
</div>
<script>
const button = document.querySelector(".button");
const sidebar = document.querySelector(".sidebar");
let isSidebarOpen = false;
let timeoutId;
sidebar.style.width = "0";
button.addEventListener("click", () => {
if (!isSidebarOpen) {
sidebar.style.width = "300px";
isSidebarOpen = true;
} else {
sidebar.style.width = "0";
button.style.right = "80px";
closeSubmenus();
isSidebarOpen = false;
}
});
function closeSubmenus() {
const submenus = document.querySelectorAll(".submenu");
submenus.forEach((submenu) => {
submenu.style.display = "none";
});
// If there's no submenu open, move the button back to right.
if (!document.querySelector('.submenu[style*="block"]')) {
button.style.right = "80px";
}
}
const menuItems = document.querySelectorAll(".menubar");
menuItems.forEach((menuItem) => {
menuItem.addEventListener("mouseover", () => {
if (isSidebarOpen) {
closeSubmenus();
const submenu = menuItem.querySelector(".submenu");
if (submenu) {
submenu.style.display = "block";
button.style.right = "310px"; // If a submenu opens, move the button right.
}
}
});
menuItem.addEventListener("mouseout", () => {
if (isSidebarOpen) {
const submenu = menuItem.querySelector(".submenu");
if (submenu && submenu.style.display === "block") {
timeoutId = setTimeout(() => {
submenu.style.display = "none";
if (!document.querySelector('.submenu[style*="block"]')) { // check if there's no other opened sub-menu
button.style.right = "80px"; // If a submenu closes, move the button back to right.
}
}, 1000); // wait for one second before closing the submenu
}
}
});
menuItem.addEventListener("mouseover", () => clearTimeout(timeoutId)); // if mouse comes back on item before timeout ends, clear the timeout
});
</script>
</body>
</html>
์์ ๊ฐ์ ์ฝ๋๋ฅผ ์์ฑํ์ฌ ์ฌ์ด๋ ๋ฐ๋ฅผ ๊ตฌ์ฑํ ์ ์์ต๋๋ค.
728x90
๋ฐ์ํ