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
5 changes: 5 additions & 0 deletions components/Box/Box.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.Box {
border: 2px solid black;
padding: 10px;
margin: 0 10px;
}
3 changes: 3 additions & 0 deletions components/Section/Section.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
section {
border: 1px solid black;
}
59 changes: 51 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
<!DOCTYPE html>
<hml>
<head>
<title>Introduction to the DOM</title>
<link rel="stylesheet" href="./styles.css">
</head>
<body>
</body>
</hml>
<html>

<head>
<title>Components-BEM</title>
<link rel="stylesheet" href="./styles.css">
<script src="./index.js" async></script>
</head>
<!-- Using BEM, create the page with three components: `Section`, `Box`, and `Dropdown`.
Using ES6 class constructors, complete the `Dropdown` component functionality. -->

<body>
<div class="Section Box">
<div class="Navbar dropdown">
<button onclick="Toggle()" class="dropbtn">Dropdown</button>
<div id="myDropdown" class="dropdown-content">
<a href="lambdaschool.com">Lambda</a>
<a href="google.com">Google</a>
<a href="https://developer.mozilla.org">MDN</a>
</div>
</div>
<div class="Block__header">
<h1>Header</h1>
</div>
</div>
<div class="Section">
<div class="Block Box">
<div class="Block__placeholder">
<h3 class="Block__h3">Placeholder</h3>
<p class="Block__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>
<div class="Section">
<div class="Block Box">
<div class="Block__placeholder">
<h3 class="Block__h3">Placeholder</h3>
<p class="Block__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>
</body>

</html>
14 changes: 14 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Dropdown {
constructor() {
this.dropDownButton = document.querySelector('.dropdown_button');
this.dropDownItems = document.querySelector('.dropdown_menu');
console.log(this.dropdownMenu);

this.dropDownButton.addEventListener('click', this.toggleMenu.bind(this));
}
toggleMenu(event) {
this.dropdownItems.classList.toggle('dropdown_menu--show');
}
}

window.onload = () => new Dropdown();
127 changes: 127 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,130 @@ body {
min-width: 300px;
margin: 0;
}

body {
min-width: 300px;
margin: 0;
}

section {
border: 1px solid black;
}

.dropdown {
position: absolute;
left: 10px;
top: 10px;
}

.dropdown__button {
background-color: white;
padding: 10px 0;
width: 200px;
font-size: 16px;
border: 1px solid black;
background-color: white;
color: black;
padding: 16px;
font-size: 16px;
border: 2px solid black;
cursor: pointer;
}

.dropdown__menu {
display: none;
margin-top: 3px;
background-color: white;
flex-direction: column;
width: 198px;
border: 1px solid black;
}

.dropdown__menu--show {
display: flex;
}

.dropdown__menu a {
text-decoration: none;
color: black;
padding: 10px 0;
text-align: center;
}

.dropdown__menu a:hover {
background-color: black;
color: white;
}

.header {
display: flex;
align-items: center;
justify-content: center;
}

.content {
display: flex;
flex-direction: row;
}

.content__block {
width: 50%;
border: 1px solid black;
padding: 10px;
}

@media(max-width: 400px) {
.content {
flex-direction: column;
}
.content__block {
width: 100%;
}
.header {
flex-direction: column-reverse;
align-items: center;
justify-content: center;
}
.dropdown {
position: inherit;
margin-bottom: 10px;
}
.dropdown__menu {
position: absolute;
}
}
/* Header {
} */
/* Dropdown Button */


/* Dropdown button on hover & focus */
.dropbtn:hover, .dropbtn:focus {
background-color: #2980B9;
}



/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}

/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}

/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #ddd}

/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */
.show {display:block;}