Skip to content
Open
34 changes: 31 additions & 3 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>
<title>Components-BEM</title>
<link rel="stylesheet" href="./styles.css">
</head>
<body>
<div class="Section">
<div class="Section__header">
<div class="Dropdown">
<p>Dropdown</p>
</div>
<div class="DropdownReveal">
<a href="#">Lambda</a>
<a href="#">Google</a>
<a href="#">MDN</a>
</div>
<h1>Header</h1>
</div>
<div class="Boxes">
<div class="Box">
<h2>Placeholder</h2>
<p>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.</p>
</div>
<div class="Box">
<h2>Placeholder</h2>
<p>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.</p>
</div>
</div>
</div>
<script type="text/javascript" src="main.js"/>
</body>
</hml>
</html>

<!-- Created Section, Box & Dropdown -->
<!-- DropdownReveal will display HTML Attribute of Lambda, Google & MDN -->
<!-- Added script tag to reference main.js for class constructors & Dropdown component functionality -->
19 changes: 19 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Added DOMString for Click & DropdownReveal //
const dropdown = document.querySelector('.Dropdown');
const reveal = document.querySelector('.DropdownReveal');

// Upon click Dropdown will display HTML Attributes //
class Dropdown {
constructor(button, list) {
button.addEventListener('click', (event) => {
list.classList.toggle('display');
});
}
}

const dd = new Dropdown(dropdown, reveal);

// Without Components //
dropdown.addEventListener('click', (event) => {
reveal.classList.toggle('display');
});
68 changes: 68 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,71 @@ body {
min-width: 300px;
margin: 0;
}

/* Create box enclosing all content */
.Section {
width: 100%;
border: 2px solid black;
display: flex;
flex-direction: column;
}

/* Aligned Header to center */
.Section__header h1 {
text-align: center;
}

/* Create border & style surrounding Dropdown button */
.Dropdown {
position: absolute;
border: 2px solid black;
padding: 0 15px;
left: 15px;
top: 15px;
}

/* Hide HTML attributes of Lambda, Google, MDN */
.DropdownReveal {
position: absolute;
border: 2px solid black;
background-color: white;
display: none;
flex-direction: column;
left: 10px;
top: 75px;
}

/* Format HTML attributes padding & width */
.DropdownReveal a {
padding: 5x;
width: 78px;
}

/* Upon click of button from index.js DropdownReveal will be displayed */
.display {
display: flex;
}

/* Assigned direction Box within Boxes */
.Boxes {
display: flex;
flex-direction: row;
}

/* Border for Box with Placeholder & Style with width & padding */
.Box {
width: 50%;
border: 2px solid black;
padding: 0 20px;
}

/* Create Media Query for Mobile device */
@media (max-width: 500px) {
.Boxes {
flex-direction: column;
}

.Box {
width: auto;
}
}