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
3 changes: 3 additions & 0 deletions components/Box/Box.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.Box{
padding: 20px;
}
26 changes: 26 additions & 0 deletions components/Dropdown/Dropdown.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.Dropdown {
display: inline-block;
margin-left: 20px;
}

.Dropdown__btn {
border: 2px solid black;
height: 40px;
}

.Dropdown__list {
flex-direction: column;
display: none;
margin-top: 10px;
background: white;
border: 2px solid black;
text-align: center;
justify-content: space-around;
position: absolute;
width: 65px;
}

.Dropdown--active {
display: flex;
height: 80px;
}
21 changes: 21 additions & 0 deletions components/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
let btn = document.querySelector('.Dropdown__btn');
let dropdown = document.querySelector('.Dropdown__list');


// btn.addEventListener('click', () => {
// dropdown.classList.toggle('Dropdown--active');
// })

// ES6 Syntax
class Dropdown {
constructor(button, dropdownMenu) {
this.button = button;
this.dropdownMenu = dropdownMenu
this.button.addEventListener('click', () => {this.showDropdown()})
}
showDropdown() {
this.dropdownMenu.classList.toggle('Dropdown--active');
}
}

btn = new Dropdown(btn, dropdown);
21 changes: 21 additions & 0 deletions components/Section/Section.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

.Section {
max-width: 1100px;
width: 100%;
margin: 0 auto;
border: 2px solid black;
}
.Section__header {
display: inline-block;
margin-left: 390px;
}

.Section--half {
width: 49%;
display: inline-block;
border: 0px;
}

.Section--border {
border-right: 2px solid black;
}
34 changes: 32 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
<!DOCTYPE html>
<hml>
<html>
<head>
<title>Introduction to the DOM</title>
<link rel="stylesheet" href="./styles.css">
<script src='./components/Dropdown/Dropdown.js' defer='defer'></script>
</head>
<body>
<div class="Section">
<div class="Dropdown">
<button class="Dropdown__btn">Dropdown</button>
<div class="Dropdown__list">
<a href="#">Lambda</a>
<a href="#">Google</a>
<a href="#">MDN</a>
</div>
</div>
<h1 class="Section__header">Header</h1>
</div>
<div class="Section">
<div class="Section Section--half Section--border">
<div class="Box">
<h3 class="Box__header">Placeholder</h3>
<div class="Box__text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce risus nibh, gravida nec felis quis, facilisis facilisis lectus. Nulla ac orci pretium, condimentum orci quis, accumsan nisi. Aliquam erat volutpat. Curabitur cursus mattis libero, at viverra risus hendrerit quis. Fusce imperdiet tristique tortor non tincidunt. Mauris accumsan urna nec augue feugiat porta. Proin vitae magna in ex malesuada laoreet eget a nulla. Aliquam tristique et elit at consequat. In hac habitasse platea dictumst.
</div>
</div>
</div><div class="Section Section--half"> <!--had to eliminate white space btwn these 2 divs since they are inline-block -->
<div class="Box">
<h3 class="Box__header">Placeholder</h3>
<div class="Box__text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce risus nibh, gravida nec felis quis, facilisis facilisis lectus. Nulla ac orci pretium, condimentum orci quis, accumsan nisi. Aliquam erat volutpat. Curabitur cursus mattis libero, at viverra risus hendrerit quis. Fusce imperdiet tristique tortor non tincidunt. Mauris accumsan urna nec augue feugiat porta. Proin vitae magna in ex malesuada laoreet eget a nulla. Aliquam tristique et elit at consequat. In hac habitasse platea dictumst.
</div>
</div>
</div>
</div>

</body>
</hml>
</html>
1 change: 1 addition & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import './components/Section/Section.css';
@import './components/Box/Box.css';
@import './components/Dropdown/Dropdown.css';

body {
box-sizing: border-box;
Expand Down