whatisthis?
practice - css / jquery ) j์ฟผ๋ฆฌ๋ก ์์ฝ๋์ธ๋ฉ๋ด ๋ง๋ค๊ธฐ ๋ณธ๋ฌธ
PRACTICE/SELF
practice - css / jquery ) j์ฟผ๋ฆฌ๋ก ์์ฝ๋์ธ๋ฉ๋ด ๋ง๋ค๊ธฐ
thisisyjin 2022. 3. 10. 12:44๐ป j-Query ์์ด ๋ง๋ ์์ฝ๋์ธ ๋ฉ๋ด
Accordion Menu
with jQuery
- ๋๋ ์ ์ด์ฟผ๋ฆฌ์ ๋ฌด๊ฑฐ์์ ๊ธฐํผ + ๊ธฐ๋ณธ ์๋ฐ์คํฌ๋ฆฝํธ์ ์ถฉ์คํ์! ๋ ๋ง์ธ๋๋ก ์ฌํ jQuery๋ฅผ ๊ตณ์ด ์์ผ์๋ค.
- But. ์ธ์ ๊ฐ ์ ์ด์ฟผ๋ฆฌ๋ฅผ ์จ์ผํ ๋๊ฐ ์๊ณ ,
ํ์ฌ ๋ง์ ํ์ด์ง๋ค์ด ์ ์ด์ฟผ๋ฆฌ๋ก ๊ตฌ์ฑ๋์ด์์ผ๋ฏ๋ก ์๊ณ ๋ ์์ด์ผ ํ๋ค (...)
๋ฐ๋ผ์, ๊ฐ๋จํ ์์ ๋ฅผ ๋ฐ๋ผํด๋ณด๋ฉด์
์ ์ด์ฟผ๋ฆฌ์ ๊ธฐ๋ณธ syntax๋ค์ ์ตํ๋ณด์.
index.html
<!DOCTYPE html>
<html lang="en">
<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>with jQuery</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="accordion">
<ul class="list">
<li class="item">
<h2 class="title">Menu</h2>
<div class="text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Est,
nostrum libero. Neque autem eligendi, rerum ducimus expedita
dignissimos quibusdam veritatis?
</div>
</li>
</ul>
<ul class="list">
<li class="item">
<h2 class="title">Menu</h2>
<div class="text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Est,
nostrum libero. Neque autem eligendi, rerum ducimus expedita
dignissimos quibusdam veritatis?
</div>
</li>
</ul>
<ul class="list">
<li class="item">
<h2 class="title">Menu</h2>
<div class="text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Est,
nostrum libero. Neque autem eligendi, rerum ducimus expedita
dignissimos quibusdam veritatis?
</div>
</li>
</ul>
<ul class="list">
<li class="item">
<h2 class="title">Menu</h2>
<div class="text">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Est,
nostrum libero. Neque autem eligendi, rerum ducimus expedita
dignissimos quibusdam veritatis?
</div>
</li>
</ul>
</div>
<script src="//code.jquery.com/jquery-latest.min.js"></script>
<script src="app.js"></script>
</body>
</html>
style.css
@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;700&display=swap");
* {
box-sizing: border-box;
margin: 0;
}
body {
font-family: "Montserrat", sans-serif;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100vh;
background-color: #81b0c7;
}
.accordion {
background-color: #fff;
width: 100%;
max-width: 600px;
}
ul {
list-style: none;
padding: 0;
}
.title {
position: relative;
width: 100%;
padding: 30px;
background-color: #000;
color: #fff;
transition: all 300ms ease-in-out;
}
.title::after {
position: absolute;
bottom: 0;
left: 0;
content: "";
width: 100%;
height: 1px;
background-color: rgba(255, 255, 255, 0.4);
}
.title:hover {
padding-left: 50px;
opacity: 0.8;
}
.text {
display: none;
padding: 20px;
background-color: #fafafa;
}
app.js
$(".title").on("click", function () {
$(this).next(".text").slideToggle(100);
});
>> ๋ค ํผ์ณ์ง๋ ๋ฒ์ ์.
+) ํ๋ ํด๋ฆญํ๋ฉด ๋๋จธ์ง ๋ค ์ ํ๊ฒ ํ๋ ค๋ฉด?
์ถํ ํฌ์คํ ์์ !
slideToogle ๋ฉ์๋ ์ด์ฉ.
'PRACTICE > SELF' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
practice - css / js ) Tab Menu (0) | 2022.03.11 |
---|---|
practice - css / jquery ) j์ฟผ๋ฆฌ๋ก ์์ฝ๋์ธ๋ฉ๋ด ๋ง๋ค๊ธฐ + ์ถ๊ฐ (1) | 2022.03.10 |
practice - css / js ) j์ฟผ๋ฆฌ ์์ด ์์ฝ๋์ธ๋ฉ๋ด ๋ง๋ค๊ธฐ (0) | 2022.03.10 |
CSS - Animation practice (0) | 2022.03.01 |
CSS - Transition practice (1) | 2022.03.01 |