Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <aside>
  <div class="header">
    <h1>Data loss</h1>
    <button class="btn-close"><svg viewBox="0 0 47.971 47.971"><path fill="white" d="M28.228 23.986L47.092 5.122a2.998 2.998 0 000-4.242 2.998 2.998 0 00-4.242 0L23.986 19.744 5.121.88a2.998 2.998 0 00-4.242 0 2.998 2.998 0 000 4.242l18.865 18.864L.879 42.85a2.998 2.998 0 104.242 4.241l18.865-18.864L42.85 47.091c.586.586 1.354.879 2.121.879s1.535-.293 2.121-.879a2.998 2.998 0 000-4.242L28.228 23.986z"/></svg></button>
  </div>

  <div class="messages">
    <div class="message agent" data-message-id="0"><p>Hello! My name is James, how can I help you today?</p></div>
    <div class="message input" data-message-id="1"><p>omg the world is burning!!! send halpppp!!</p></div>
    <div class="message agent" data-message-id="2"><p>Not to worry. What kind of help are you looking for?</p></div>
    <div class="message input" data-message-id="3"><p>THE KIND THAT WILL STOP ME FROM DYING???</p></div>
    <div class="message agent" data-message-id="4"><p>Sure thing, we can definitely help with that. Where should we send aforementioned help?</p></div>
  </div>

  <div class="controls">
    <form>
      <input type="text">
      <input type="submit" value="Send">
    </form>
  </div>
</aside>

<aside>
  <div class="header">
    <h1>No data loss</h1>
    <button class="btn-close"><svg viewBox="0 0 47.971 47.971"><path fill="white" d="M28.228 23.986L47.092 5.122a2.998 2.998 0 000-4.242 2.998 2.998 0 00-4.242 0L23.986 19.744 5.121.88a2.998 2.998 0 00-4.242 0 2.998 2.998 0 000 4.242l18.865 18.864L.879 42.85a2.998 2.998 0 104.242 4.241l18.865-18.864L42.85 47.091c.586.586 1.354.879 2.121.879s1.535-.293 2.121-.879a2.998 2.998 0 000-4.242L28.228 23.986z"/></svg></button>
  </div>

  <div class="messages">
    <div class="message agent" data-message-id="0"><p>Hello! My name is James, how can I help you today?</p></div>
    <div class="message input" data-message-id="1"><p>omg the world is burning!!! send halpppp!!</p></div>
    <div class="message agent" data-message-id="2"><p>Not to worry. What kind of help are you looking for?</p></div>
    <div class="message input" data-message-id="3"><p>THE KIND THAT WILL STOP ME FROM DYING???</p></div>
    <div class="message agent" data-message-id="4"><p>Sure thing, we can definitely help with that. Where should we send aforementioned help?</p></div>
  </div>

  <div class="controls">
    <form>
      <input type="text">
      <input type="submit" value="Send">
    </form>
  </div>
</aside>
              
            
!

CSS

              
                :root {
  --primary: teal;
  --secondary: lightcoral;
  --txt-light: white;
  --background: rgba(255, 255, 255, 0.7);
}

html {
  box-sizing: border-box;
  height: 100%;
  scroll-behavior: smooth;
}

*,
*::before,
*::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

body {
  height: 100%;
  font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  transform: translate3d(0, 0, 0);
  overflow: hidden;
  font-size: 1.5em;
}

aside {
  position: fixed;
  top: 0;
  display: flex;
  flex-direction: column;
  min-width: 15em;
  width: 25%;
  height: 100%;
  background: var(--background);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.24);
  transition: transform 0.5s ease;
}

aside:first-of-type {
  left: 0;
  
  .messages {
    justify-content: flex-end;
  }
}

aside:nth-of-type(2) {
  right: 0;
  
  .message:first-child {
    margin-top: auto;
  }
}

.header {
  text-align: center;
  padding: 0.5em;
  background-color: var(--primary);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.24);
  line-height: 1.3;
  color: #fff;
  display: flex;
  align-items: center;
}

.btn-close {
  margin-left: auto;
  height: 2em;
  width: 2em;
  background: transparent;
  border: none;
}

.btn-close svg {
  height: 1em;
  width: 1em;
}

.messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: scroll;
  padding: 1em 1.5em 0;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.24);
}

.message {
  display: flex;
  align-items: center;
}

.message p {
  border-radius: 0.25em;
  padding: 0.5em;
  margin-bottom: 1em;
}

.message.agent {
  position: relative;
}

.message.agent::after {
  content: "";
  position: absolute;
  left: -15px;
  bottom: 1em;
  border: 0 solid transparent;
  border-top: 9px solid var(--primary);
  border-radius: 0 20px 0;
  width: 15px;
  height: 30px;
  transform: rotate(145deg);
}

.message.agent p {
  background-color: var(--primary);
  color: var(--txt-light);
  border-radius: 4px;
}

.message.input {
  position: relative;
  align-self: flex-end;
}

.message.input::after {
  content: "";
  position: absolute;
  right: -15px;
  bottom: 1em;
  border: 0 solid transparent;
  border-top: 9px solid var(--secondary);
  border-radius: 0 20px 0;
  width: 15px;
  height: 30px;
  transform: rotate(45deg) scaleY(-1);
  
}

.message.input p {
  background-color: var(--secondary);
  text-align: right;
  color: var(--txt-light);
}

.controls {
  padding: 0.5em;
  background-color: var(--txt-light);
  border-top: 2px solid rgba(0, 0, 0, 0.1);
}

form {
  display: flex;
  flex-direction: row;
  justify-content: center;
  margin: 0;
}

input[type="text"] {
  flex: 1;
  font-size: 100%;
  max-width: calc(100% - 4em);
}

input[type="submit"] {
  font-size: 100%;
  border-radius: 4px;
  margin-left: 0.5em;
  height: 2em;
  padding: 0 0.5em;
  background-color: var(--primary);
  color: var(--txt-light);
}

              
            
!

JS

              
                /* 
Note, if you want the messages to automatically display the latest message at the bottom. You're gonna need Javascript for that. Use scroll().
*/
              
            
!
999px

Console