Skip to content

Instantly share code, notes, and snippets.

@Comandeer Comandeer/test.html
Last active Aug 29, 2015

Embed
What would you like to do?
rAF makeEqual
<!DOCTYPE html>
<html lang="pl" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Ehhhh</title>
<style>
html, body
{
margin: 0;
padding: 0;
height: 100%;
}
.col
{
float: left;
width: 33%;
background: #f00;
}
.col:nth-child(2)
{
background: #0f0;
}
</style>
</head>
<body>
<div class="col">1</div>
<div class="col">2</div>
<div class="col">3</div>
<script>(function equalHeight(container, cols, prev)
{
var h = container.innerHeight ? container.innerHeight : container.scrollHeight;
if(prev !== h)
{
console.log('różne');
cols.forEach(function(col)
{
col.style.height = h + 'px';
});
prev = h;
}
requestAnimationFrame(function()
{
equalHeight(container, cols, prev);
});
}(window, [].slice.call(document.querySelectorAll('.col'))));</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.