-
-
Save elijahmanor/9515381 to your computer and use it in GitHub Desktop.
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
#box { | |
width: 200px; | |
height: 200px; | |
padding: 10px; | |
margin: 5px; | |
border: 1px solid black; | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Welcome to JS Bin</title> | |
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
</head> | |
<body> | |
<div id="box"> | |
</div> | |
</body> | |
</html> |
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
var $box = $("#box"); | |
console.clear(); | |
console.log($box.width()); // 200 | |
console.log($box.innerWidth()); // 220 | |
console.log($box.outerWidth()); // 222 | |
console.log($box.outerWidth(true)); // 232 | |
console.log(""); | |
var box = document.getElementById("box"); | |
console.log(box.clientWidth); // 220 | |
console.log(box.offsetWidth); // 222 | |
console.log(box.getBoundingClientRect().width); // 222 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment