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
- HTML
- react
- hover
- ipad
- xcode
- php
- 프론트엔드
- iPhone
- button
- MAC
- SWIFT
- 풀스택
- effect
- CSS
- css3
- front-end
- 자바스크립트
- jQuery
- 비전공자
- 애니메이션
- image
- html5
- javascript
- 백엔드
- Animation
- 개발자
- IOS
- iOS 개발자
- keyframes
- 비전공 개발자
Archives
- Today
- Total
비전공자 개발일기
Javascript - Expanding Cards 본문
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>Expanding Cards</title>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
</head>
<body>
<div class="container">
<div class="panel active" style="background-image: url('./images/1.jpg');">
<h3>Explore the Space</h3>
</div>
<div class="panel" style="background-image: url('./images/2.jpg');">
<h3>Explore the Space</h3>
</div>
<div class="panel" style="background-image: url('./images/3.jpg');">
<h3>Explore the Space</h3>
</div>
<div class="panel" style="background-image: url('./images/4.jpg');">
<h3>Explore the Space</h3>
</div>
<div class="panel" style="background-image: url('./images/5.jpg');">
<h3>Explore the Space</h3>
</div>
</div>
</body>
</html>
@import url('https://fonts.googleapis.com/css2?family=Muli&display=swap');
* {
box-sizing: border-box;
}
body {
font-family: 'Muli', sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
overflow: hidden;
margin: 0;
}
.container {
display: flex;
width: 90vw;
}
.panel {
background-size: cover;
background-position: center;
background-repeat: no-repeat;
height: 80vh;
border-radius: 50px;
color: #fff;
cursor: pointer;
flex: .5;
margin: 10px;
position: relative;
transition: flex .7s ease-in;
}
.panel h3 {
font-size: 24px;
position: absolute;
bottom: 20px;
left: 20px;
margin: 0;
opacity: 0;
}
.panel.active {
flex: 5;
}
.panel.active h3 {
opacity: 1;
transition: opacity .8s ease-in .4s;
}
@media(max-width: 480px) {
.container {
width: 100vw;
}
.panel:nth-of-type(4),
.panel:nth-of-type(5) {
display: none;
}
}
const panels = document.querySelectorAll(".panel");
panels.forEach(panel => {
panel.addEventListener("click", () => {
removeActiveClasses()
panel.classList.add("active")
})
})
function removeActiveClasses() {
panels.forEach(panel => {
panel.classList.remove("active")
})
}
728x90
LIST
'Javascript' 카테고리의 다른 글
Javascript - Rotating Navigation (0) | 2021.09.27 |
---|---|
Javascript - Progress Steps (0) | 2021.09.26 |
Javascript - Vertical Slider (0) | 2021.09.24 |
Javascript - Blurry Loading (0) | 2021.09.23 |
Javascript - Dynamic Banner (0) | 2021.09.22 |