Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions solutions/dom_manipulation/2/2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
}
body{
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.container{
width: 250px;
height: auto;
text-align: center;
position: relative;
}
.container button {
width: 7rem;
height: 3rem;
background: transparent;
border: 2px solid #000;
border-radius: 30px;
font-size: 1rem;
cursor: pointer;
}
.container .items-container{
position: absolute;
top: 3rem;
left: 50%;
transform: translateX(-50%);
width: 205px;
height: auto;
display: none;
}
.container #items{
display: flex;
flex-direction: column;
text-align: start;
padding: 10px;
background-color: #fff;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
border-radius: 10px;
}
.container #items .item{
padding: 5px 10px;
border-radius: 5px;
cursor: pointer;
transition: .3s;
}

.container #items .item:hover{
font-weight: bold;
background-color: rgb(187, 187, 187);
}
23 changes: 23 additions & 0 deletions solutions/dom_manipulation/2/2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dom Manipulation 2nd challenge Menu toggle</title>
<link rel="stylesheet" href="2.css">
</head>
<body>
<div class="container">
<button>Menu</button>
<div class="items-container">
<div id="items">
<span class="item">Download image</span>
<span class="item">Hide pin</span>
<span class="item">Report Pin</span>
<span class="item">Get Pin embed code</span>
</div>
</div>
</div>
</body>
<script src="2.js"></script>
</html>
14 changes: 14 additions & 0 deletions solutions/dom_manipulation/2/2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const items_container = document.querySelector(".items-container");
const button = document.querySelector("button");

button.addEventListener("click", () => {
if(items_container.style.display === "none"){
items_container.style.display = "block"
button.style.backgroundColor = "#000"
button.style.color = "#fff"
}else{
items_container.style.display = "none"
button.style.backgroundColor = "transparent"
button.style.color = "#000"
}
})