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
16 changes: 16 additions & 0 deletions components/Box/Box.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.box--display {
display: flex;
}

.box--column {
border: 2px solid black;
padding: 1rem;
}

.box--paragraph {
font-size: 1.4rem;
}

.box__heading {
font-size: 2.2em;
}
15 changes: 15 additions & 0 deletions components/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Dropdown {
constructor(button) {
this.button = button;
this.content = document.querySelector('.section__dropdownContent');
this.button.addEventListener('click', () => {
this.openDropdown();
});
}
openDropdown() {
this.content.classList.toggle('show');
}
}
let button = new Dropdown(document.querySelector('.section__dropdownButton'));


44 changes: 44 additions & 0 deletions components/Section/Section.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
.section--display {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
}

.section--heading {
justify-content: center;
width: 80%;
font-size: 1.5em;
}

.section--dropdown {
justify-content: flex-start;
margin-left: 1em;
width: 70%;
}

.section__dropdownButton {
background: none;
border: 3px solid black;
padding: 1em;
}

.section__dropdownContent {
display: none;
position: absolute;
background-color: #fff;
min-width: 87px;
z-index: 1;
border: 3px solid black;
margin-top: 1.1em;
}

.section__dropdownContent a {
padding: 12px 16px;
display: block;
font-size: 1.5em;
}

.show {
display:block;
}
28 changes: 26 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
<!DOCTYPE html>
<hml>
<html>
<head>
<title>Introduction to the DOM</title>
<link rel="stylesheet" href="./styles.css">
<script type="text/javascript" src="./components/Dropdown/Dropdown.js" async></script>
</head>
<body>
<div class="section section--display">
<div class="section__dropdown section--dropdown">
<button class="section__dropdownButton">Dropdown</button>
<div id="myDropdown" class="section__dropdownContent">
<a href="#">Lambda</a>
<a href="#">Google</a>
<a href="#">MDN</a>
</div>
</div>
<div class="section__heading section--heading">
<h1 class="section__headingHeader">Header</h1>
</div>
</div>
<div class="box box--display">
<div class="box__column box--column">
<h2 class="box__heading">Placeholder</h2>
<p class="box__paragraph box--paragraph">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__column box--column">
<h2 class="box__heading">Placeholder</h2>
<p class="box__paragraph box--paragraph">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>
</body>
</hml>
</html>
4 changes: 4 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@import './components/Section/Section.css';
@import './components/Box/Box.css';

html {
font-size: 62.5%;
}

body {
box-sizing: border-box;
min-width: 300px;
Expand Down