Skip to content

Instantly share code, notes, and snippets.

@natevw
Created April 1, 2014 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natevw/9925186 to your computer and use it in GitHub Desktop.
Save natevw/9925186 to your computer and use it in GitHub Desktop.
<!doctype html>
<html><head>
<meta charset="utf-8">
<title>Inset border styling</title>
<style>
.list {
box-shadow: inset 3px 3px 10px grey;
height: 95px;
width: 150px;
overflow: auto;
}
.wrapper {
position: relative;
z-index: -1;
}
.item {
display: block;
width: 100px;
height: 25px;
background: yellow;
margin: 5px;
}
.item:nth-child(even) {
background: green;
}
.item.workaround { /* needed for proper redraw on scroll */
-webkit-transform: translatez(0);
}
</style>
</head><body>
<div class=list>
<div class=wrapper>
<span class=item>Item</span>
<span class=item>Item</span>
<span class=item>Item</span>
<span class=item>Item</span>
<span class=item>Item</span>
<span class=item>Item</span>
<span class=item>Item</span>
<span class=item>Item</span>
</div>
</div>
<button>Toggle workaround</button>
<script>
document.querySelector('button').addEventListener('click', function () {
var items = document.querySelectorAll('.item');
Array.prototype.forEach.call(items, function (el) {
el.classList.toggle('workaround');
});
}, false);
</script>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment