Skip to content

Instantly share code, notes, and snippets.

@starzonmyarmz
Created December 23, 2011 02:49
Show Gist options
  • Save starzonmyarmz/1512898 to your computer and use it in GitHub Desktop.
Save starzonmyarmz/1512898 to your computer and use it in GitHub Desktop.
fooling around with css and js some more
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>untitled</title>
<style>
body {
margin: 0;
padding: 0;
}
div {
background: #000;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
color: #000;
height: 25px;
left: 0;
position: absolute;
top: 100px;
width: 0;
}
</style>
</head>
<body>
<div id="btn"></div>
<script>
var b = document.getElementById('btn'),
z = 0,
f = true;
var x = function() {
var divW = b.offsetWidth;
if (f && divW < document.body.offsetWidth) {
z += 1;
} else {
f = false;
b.style.left = 'auto';
b.style.right = 0;
}
if (!f && divW > 0) {
z -= 1;
} else {
f = true;
b.style.left = 0;
b.style.right = 'auto';
}
b.style.width = z + 'px';
}
var y = setInterval(x, 10);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment