250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- css3
- 비전공 개발자
- 자바스크립트
- 백엔드
- javascript
- 프론트엔드
- react
- jQuery
- button
- php
- 애니메이션
- Animation
- 개발자
- IOS
- image
- iPhone
- CSS
- ipad
- html5
- xcode
- front-end
- hover
- HTML
- 풀스택
- 비전공자
- effect
- iOS 개발자
- MAC
- SWIFT
- keyframes
Archives
- Today
- Total
비전공자 개발일기
Animated Magic Menu Indicator 본문
728x90
SMALL
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ANIMATED MAGIC INDICATOR</title>
<link rel="stylesheet" href="style.css">
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css' integrity='sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==' crossorigin='anonymous'/>
<script defer src="main.js"></script>
</head>
<body>
<div class="navigation">
<ul>
<li class="list active" data-color ="#F53B57">
<a href="#">
<span class="icon"><i class="fa-solid fa-house"></i></span>
<span class="title">Home</span>
</a>
</li>
<li class="list" data-color="#3C40C6">
<a href="#">
<span class="icon"><i class="fa-solid fa-user"></i></span>
<span class="title">Profile</span>
</a>
</li>
<li class="list" data-color="#05C46B">
<a href="#">
<span class="icon"><i class="fa-solid fa-message"></i></span>
<span class="title">Message</span>
</a>
</li>
<li class="list" data-color="#0FBCF9">
<a href="#">
<span class="icon"><i class="fa-solid fa-circle-question"></i></span>
<span class="title">Help</span>
</a>
</li>
<li class="list" data-color="#FFA801">
<a href="#">
<span class="icon"><i class="fa-solid fa-gear"></i></span>
<span class="title">Settings</span>
</a>
</li>
<div class="indicator"></div>
</ul>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #F53B57;
transition: .5s;
}
.navigation {
position: relative;
width: 70px;
height: 350px;
background-color: #FFF;
border-radius: 35px;
box-shadow: 0 15px 25px rgba(0, 0, 0, .1);
}
.navigation ul {
position: absolute;
top: 0;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
}
.navigation ul li {
position: relative;
list-style: none;
width: 70px;
height: calc(350px / 5);
z-index: 1;
}
.navigation ul li a {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
text-align: center;
color: #333;
font-weight: 500;
}
.navigation ul li a .icon {
position: relative;
display: block;
line-height: 75px;
text-align: center;
transition: .5s;
}
.navigation ul li.active a .icon {
color: #FFF;
}
.navigation ul li .icon i {
font-size: 24px;
}
.navigation ul li a .title {
position: absolute;
top: 50%;
left: 110px;
background-color: #FFF;
transform: translateY(-50%);
padding: 5px 10px;
border-radius: 6px;
transition: .5s;
box-shadow: 0 5px 15px rgba(0, 0, 0, .1);
opacity: 0;
visibility: hidden;
}
.navigation ul li:hover a .title {
opacity: 1;
visibility: visible;
transform: translate(-25px, -50%);
}
.navigation ul li a .title::before {
content: '';
position: absolute;
width: 12px;
height: 12px;
background-color: #FFF;
left: -10px;
top: 46%;
transform: rotate(45deg) translateY(-50%);
border-radius: 2px;
}
.navigation ul .indicator {
position: absolute;
left: 0;
width: 70px;
height: 70px;
transition: .5s;
}
.navigation ul .indicator::before {
content: "";
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 50px;
height: 50px;
background-color: #333;
border-radius: 50%;
transition: .5s;
}
.navigation ul li:nth-child(1).active ~ .indicator {
transform: translateY(calc(70px * 0));
}
.navigation ul li:nth-child(2).active ~ .indicator {
transform: translateY(calc(70px * 1));
}
.navigation ul li:nth-child(3).active ~ .indicator {
transform: translateY(calc(70px * 2));
}
.navigation ul li:nth-child(4).active ~ .indicator {
transform: translateY(calc(70px * 3));
}
.navigation ul li:nth-child(5).active ~ .indicator {
transform: translateY(calc(70px * 4));
}
.navigation ul li:nth-child(1).active ~ .indicator::before {
background-color: #F53B57;
}
.navigation ul li:nth-child(2).active ~ .indicator::before {
background-color: #3C40C6;
}
.navigation ul li:nth-child(3).active ~ .indicator::before {
background-color: #05C46B;
}
.navigation ul li:nth-child(4).active ~ .indicator::before {
background-color: #0FBCF9;
}
.navigation ul li:nth-child(5).active ~ .indicator::before {
background-color: #FFA801;
}
// Add active class on hovered item
let list = document.querySelectorAll("li");
for(let i = 0; i < list.length ; i++) {
list[i].onmouseover = function() {
let j = 0;
while(j < list.length) {
list[j++].className = 'list';
}
list[i].className = "list active"
}
}
// change body color according to indicator
list.forEach(elements => {
elements.addEventListener('mouseenter', function(event) {
let bg = document.querySelector("body");
let color = event.target.getAttribute('data-color');
bg.style.backgroundColor = color;
})
})
728x90
LIST
'HTML _CSS' 카테고리의 다른 글
Animated Hot Cup of Tea (0) | 2022.06.26 |
---|---|
Dark Card Hover Effect (0) | 2022.06.25 |
Switch Text Effect (0) | 2022.06.23 |
Project Management Dashboard (0) | 2022.06.22 |
Sliding Card UI Design (0) | 2022.06.19 |