-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5829e5
commit 73c9b49
Showing
4 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Javascript Nuggets | ||
// Width/Height - window, any element | ||
// innerHeight | ||
// innnerWidth | ||
// getBoundingClientRect | ||
|
||
console.log('height', window.innerHeight) | ||
console.log('width', window.innerWidth) | ||
|
||
const btn = document.querySelector('.btn') | ||
const box = document.querySelector('.box') | ||
|
||
btn.addEventListener('click', () => { | ||
const dimensions = box.getBoundingClientRect() | ||
console.log(dimensions) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Javascript Nuggets</title> | ||
<link rel="stylesheet" href="../global.css" /> | ||
<style> | ||
body { | ||
min-height: 130vh; | ||
} | ||
h1 { | ||
text-align: center; | ||
} | ||
.btn { | ||
display: block; | ||
width: 200px; | ||
margin: 0 auto; | ||
margin-top: 3rem; | ||
} | ||
.box { | ||
width: 150px; | ||
height: 150px; | ||
background: grey; | ||
margin: 0 auto; | ||
margin-top: 4rem; | ||
margin-left: -1rem; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Width/Height</h1> | ||
<button class="btn">Get Dimensions</button> | ||
<div class="box"></div> | ||
<script src="./app.js"></script> | ||
</body> | ||
</html> |