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
32 changes: 30 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
<!DOCTYPE html>
<hml>
<html>
<head>
<title>Introduction to the DOM</title>
<link rel="stylesheet" href="./styles.css">
<script defer="defer" src="script.js"></script>
</head>
<body>
<header>
<div class="Dropdown">
<div class="Dropdown__button">
<p>Dropdown</p>
</div>
<div class="Dropdown__content">
<li>Lambda</li>
<li>Google</li>
<li>MDN</li>
</div>
</div>
<h1>
Header
</h1>
</header>

<div class="container">
<div class="box">
<h2>Placeholder</h2>
<p>Some text here</p>
</div>
<div class="box">
<h2>Placeholder</h2>
<p>Some text here</p>
</div>
</div>

</body>
</hml>
</html>
30 changes: 30 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
let dropdowns = document.querySelector('.Dropdown');

class DropdownMenu {
constructor(eb) {
this.element = eb;
this.button = this.element.querySelector('.Dropdown__button');
this.button.addEventListener('click', () => {
this.dropdownAction();
});
}
dropdownAction() {
this.element.classList.toggle('Dropdown--active');
}
}



dropdowns = new DropdownMenu(dropdowns);


// dropdowns = Array.from(dropdowns).map((dropdown) => {console.log(dropdowns);
// })


//Testing
// dropdowns = Array.from(dropdowns).map((dropdown) => new DropdownMenu(dropdown));

// dropdowns = Array.from(dropdowns).map( (dropdown) => {
// console.log(dropdown);
// })
44 changes: 44 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,52 @@
@import './components/Section/Section.css';
@import './components/Box/Box.css';


body {
box-sizing: border-box;
min-width: 300px;
margin: 0;
max-width: 1024px;
}

header {
display:flex;
width: 100%;
border: 2px solid black;
}

.Dropdown {
border: 2px solid black;
align-self: flex-start;
}

header .h1 {
font-size: 30px;
margin-left: 1000px;
}

header .Dropdown__content {
position: absolute;
margin-top:60px;
background-color: grey;
display: none;
}

.Dropdown--active .Dropdown__content {
display:block;
}

.container {
display:flex;
justify-content: space-evenly;
border: 2px black solid;

}

.container .box {
width: 50%;
border: 2px black solid;
display:flex;
flex-direction: column;
padding: 10px 10px;
}