Created
January 16, 2013 19:00
-
-
Save cbmeeks/4549765 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<html> | |
<body style="margin:0;"> | |
<div id="d" style="background:#ff0;left:200px;position:relative;"> | |
Hello | |
</div> | |
</body> | |
</html> |
This file contains hidden or 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
// document resized to 1503 pixels | |
document.getElementById('d').getClientRects()[0].width; | |
// 1303 pixels | |
// we know it has a "left" of 200 px | |
// so, 1503 - 1303 yields how many pixels are "off the screen" | |
// If your margins were 8px, then you would subtract 8px. Because there would be 8 on the left and 8 on the right. But your | |
// width would then be 1303 - 16 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment