LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

Simple Responsive Chat / Messenger

Go ahead and add a message.

  • Chris Hutchinson

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porta condimentum ante id tristique. Nulla eget vestibulum dolor.

  • Nic Cage

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus porta condimentum ante id tristique. Nulla eget vestibulum dolor.

CSS
*, *:before, *:after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  height: 100%;
  font-family: 'Lato', sans-serif;
  font-weight: 300;
  font-size: 14px;
  background: #eaeaea;
  overflow: auto;
  margin: 0;
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #EBE7DE), color-stop(1, #CBC7B7));
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 300;
  margin: 0;
}

h1.title {
  padding: 7px 20px 10px;
  margin: 0 0 20px 0;
  background: #333;
  color: #FFF;
  width: 100%;
  font-size: 1.4em;
}

p.description {
  padding: 0 20px;
}

ul {
  letter-spacing: -4px;
}
ul li {
  letter-spacing: normal;
}

ul.messages {
  padding: 20px;
  list-style-type: none;
  margin: 0 0 130px 0;
  overflow: hidden;
}
ul.messages li.message {
  display: block;
  clear: both;
  overflow: hidden;
  margin: 0 0 10px 0;
}
ul.messages li.message img.user {
  height: auto;
  width: 70px;
  border-radius: 50%;
  float: left;
  margin: 0 20px 20px 0;
}
ul.messages li.message h1.name {
  display: block;
  font-size: 1.2em;
  text-transform: uppercase;
  color: #8b8b8b;
  margin: 0 0 5px 0;
  text-align: right;
}
ul.messages li.message p.text {
  display: block;
  background-color: rgba(221, 246, 255, 0.6);
  padding: 7px 20px;
  margin: 0 0 0 35px;
  line-height: 1.4em;
  border-radius: 0px 4px 4px 4px;
}
ul.messages li.message p.text:hover {
  background-color: rgba(221, 246, 255, 0.8);
}
ul.messages li.message:nth-of-type(2n) h1.name {
  text-align: left;
}
ul.messages li.message:nth-of-type(2n) img.user {
  float: right;
  margin: 0 0 10px 10px;
}
ul.messages li.message:nth-of-type(2n) p.text {
  background-color: rgba(221, 255, 235, 0.6);
  margin: 0 35px 0 0;
  border-radius: 4px 0 4px 4px;
}
ul.messages li.message:nth-of-type(2n) p.text:hover {
  background-color: rgba(221, 255, 235, 0.8);
}

textarea.message {
  position: fixed;
  bottom: 30px;
  left: 0;
  width: 100%;
  border: 0;
  padding: 10px;
  font-family: 'Lato', sans-serif;
  font-weight: 300;
  height: 100px;
  -webkit-appearance: none;
  outline: 0;
  border-top: 3px solid #3e3e3e;
  background: rgba(255, 255, 255, 0.7);
}
textarea.message:focus {
  background: white;
}
textarea.message.required {
  background: #ffdddd;
}

div.actions {
  position: fixed;
  bottom: 0;
  left: 0;
  height: 30px;
  background: #FFF;
  width: 100%;
}
div.actions button {
  float: right;
  width: 100%;
  height: 30px;
  font-size: 1.1em;
  background: #3e3e3e;
  color: #FFF;
  border: 0;
  padding: 5px 12px;
  -webkit-appearance: none;
  outline: 0;
  font-family: 'Lato', sans-serif;
  font-weight: 300;
  cursor: pointer;
}
div.actions button:hover {
  background: #252525;
}
JS
$(document).ready(function(){
  $('button').click(function(){
    var value = $('textarea.message').val();
    if(value != ''){
      var message = $('li.message').first().clone();
      $(message).find('p.text').html(value);
      $('ul.messages').append(message);
      $('textarea.message').val('');
      $('html, body').animate({ scrollTop: $(document).height() }, 700);
      $('textarea.message').removeClass('required');
    } else {
      $('textarea.message').addClass('required');
    }
  });
});
Host Instantly Drag and Drop Website Builder

 

Description

A simple chat layout allowing users to add messages, and scrolling to the latest.
Term
Mon, 11/27/2017 - 22:01

Related Codes

Pen ID
Pen ID
Pen ID