Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


      <h1>overscroll-behavior demo</h1>

    <section class="chatbox">
        <h2>Active chat</h2>
      <div class="messages">
        <p class="me">Chris: Hello!</p>
        <p class="you">Bob: I am well — how are you?</p>
        <p class="me">Chris: Fine thanks, just documenting overscroll-behavior</p>
        <p class="you">Bob: Oooh, sounds hard!</p>
        <p class="me">Chris: Nah, it's OK really. It is a useful property to have for mobile apps especially.</p>
        <p class="you">Bob: Cool, where can I learn more?</p>
        <input type="text" aria-label="Enter your chat message here" autofocus>
      <p>Copyright nobody; inspired by <a href="">ebidel's chatbox demo</a>.</p>


                /* General set up */

* {
  box-sizing: border-box;

html {
  font-family: sans-serif;

body {
  margin: 0;
  /* Use overscroll-behavior to stop the "bounce" or refresh effect you get on mobile
  browsers when getting to the top or bottom scroll limits of the page */
  overscroll-behavior: none;

/* Styling of contacts */

header, footer {
  background-color: #a60000;
  color: white;
  text-align: center;
  height: 50px;
  line-height: 50px;
  text-shadow: 2px 2px 1px black;

h1, h2 {
  margin: 0;

main div {
  padding: 10px 20px;
  border-bottom: 1px solid #eee;

p {
  margin: 0;

a {
  color: #ccc;

main div p {
  line-height: 20px;

body > header {
  position: sticky;
  top: 0;

/* Styling of chatbox */

.chatbox {
  background: white;
  width: 200px;
  height: 300px;
  border: 1px solid black;
  position: fixed;
  bottom: 10px;
  right: 10px;

.messages {
  height: 220px;
  overflow: auto;
  /* use overscroll-behavior-y to stop page scrolling behind the chatbox,
  when the chatbox's scroll limits are reached */
  overscroll-behavior-y: contain;

.messages p {
  margin: 10px;
  padding: 10px;
  border-radius: 3px;

.me {
  background-color: #bbb;

.you {
  background-color: #eee;
  text-align: right;

.chatbox form {
  height: 30px;
  display: flex;

form input, form button {
  display: block;

form input {
  width: 70%;

form button {
  width: 30%;
  font-size: 0.7rem;



                // Generate fake contacts

let mainElem = document.querySelector('main');

for(var i = 1; i < 51; i++) {
  let divElem = document.createElement('div');
  let pElem = document.createElement('p');

  pElem.textContent = 'Contact ' + i;


// Allow submission of chat messages

let form = document.querySelector('form');
let input = document.querySelector('input');
let messages = document.querySelector('.messages');
messages.scrollTop = messages.scrollHeight;

form.addEventListener('submit', e => {

  if(input.value !== '') {
    let pElem = document.createElement('p');
    pElem.setAttribute('class', 'me');
    pElem.textContent = 'Chris: ' + input.value;

    messages.scrollTop = messages.scrollHeight;

    input.value = '';