Skip to content

Instantly share code, notes, and snippets.

@elijahmanor
Forked from anonymous/jsbin.polacoha.css
Created March 12, 2014 20:15
Show Gist options
  • Save elijahmanor/9515381 to your computer and use it in GitHub Desktop.
Save elijahmanor/9515381 to your computer and use it in GitHub Desktop.
#box {
width: 200px;
height: 200px;
padding: 10px;
margin: 5px;
border: 1px solid black;
}
<!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>
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