Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save akirchmyer/7508640 to your computer and use it in GitHub Desktop.

Select an option

Save akirchmyer/7508640 to your computer and use it in GitHub Desktop.
A Pen by Andrew Kirchmyer.
<div class="mydiv"><p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p></div>
.mydiv {
/* Set up the scroll area */
width: 200px;
height: 200px;
margin: 0 auto;
overflow: auto;
/* two backgrounds: one visible at the bottom, the other at the top. they create the shadow effect which can be used to indicate content above and below */
background: radial-gradient(at 50% 0, rgba(0,0,0,.3), transparent 70%),radial-gradient(at 50% 100%, rgba(0,0,0,.3), transparent 70%) bottom;
/* background fills the whole container */
background-size: 100% 15px;
background-repeat: no-repeat;
/* background is not fixed, you can scroll the background with the content */
background-attachment: local;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment