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

              
                <div class="wrapper">
  <div class="mobile">
    <div class="container">
      <div class="chatMsg">
        <ul>
          <li>
            <div class="avatar">
              <img src="https://pickaface.net/gallery/avatar/20120828_115442_2229_tete.png" width="32" height="32" alt>
            </div>
            <div class="msg">Lorem ipsum dolor sit amet, consectetur adipiscing elit</div>                   </li>          
        </ul>
      </div>
      <div class="chatBox">
        <span class="mdi mdi-attachment"></span>
        <span class="mdi mdi-send disabled"></span>
        <textarea rows="1" placeholder="Write a response" id="msgTypeBox"></textarea>        
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                $base-size: 13px
$line-height: 22px
$base-family: "Montserrat",sans-serif
$primary-color: #4d61a6 
$secondary-color: #67deb4

@mixin borderRadius($value)
  -webkit-border-radius: $value
  -moz-border-radius: $value
  border-radius: $value

*
  box-sizing: border-box
  font-size: $base-size
  line-height: $line-height
  font-family: $base-family

body
  font-size: $base-size
  font-family: $base-family
.wrapper
  width: 322px
  margin: 0 auto
  
.mobile
  background: url(http://www.binpress.com/images/stores/store12915/Chatt%20Android%20Splash%20Screen%20-%20Front.png) no-repeat center top
  width: 322px
  padding: 75px 20px
  
.container
  width: 281px
  height: 493px
  background: #eee
  position: relative

.chatMsg
  padding: 15px
  overflow-y: auto
  height: calc(100% - 45px)
  ul
    margin: 0
    padding: 0
    list-style: none
    li
      position: relative
      margin-bottom: 15px
.msg
  display: block
  margin-left: 45px
  background: #fff
  padding: 10px 15px  
  position: relative
  box-shadow: 0 1px 10px rgba(0,0,0, 0.25)
  &::before
    position: absolute
    left: -12px
    top: 12px
    content: ""
    display: block
    border-right: 12px solid #fff    
    border-bottom: 15px solid transparent
.msg-reply
  margin-left: inherit
  margin-right: 45px
  background: $primary-color
  color: #fff
  @extend .msg
  &::before
    left: inherit
    right: -12px
    border-right: inherit
    border-left: 12px solid $primary-color
.avatar
  position: absolute
  left: 0
  overflow: hidden
  width: 30px
  height: 30px
  @include borderRadius(30px)
  img
    max-width: 30px 
.avatar-reply
  left: inherit
  right: 0
  @extend .avatar  
  
.chatBox
  position: absolute
  bottom: 0
  left: 0
  right: 0
  .mdi-attachment
    position: absolute
    z-index: 2
    left: 10px
    font-size: 20px
    bottom: 15px
    color: $primary-color
    cursor: pointer
  .mdi-send
    width: 32px
    height: 32px
    line-height: 32px
    position: absolute
    z-index: 2
    bottom: 8px
    right: 10px
    font-size: 16px
    color: #fff
    background: $primary-color
    text-align: center
    cursor: pointer
    @include borderRadius(32px)
    &.disabled
      opacity: 0.5
      pointer-events: none
  textarea
    display: block
    resize: none
    width: 100%
    border: 0
    border-top: 1px solid #ccc
    background: #fff
    padding: 12px 50px 12px 40px
    position: absolute
    bottom: 0
    min-height: 45px
    overflow: hidden
 
.hiddendiv
  display: none 
  
              
            
!

JS

              
                $(".mdi-send").on("click", function() {
  var typeMsg = $("#msgTypeBox").val(); 
  if(typeMsg =="") {
    return false;    
  } else {     
    $(".chatMsg ul").append("<li><div class='avatar-reply'><img src='https://bootdey.com/img/Content/avatar/avatar6.png'></div><div class='msg-reply'>"+typeMsg+"</div></li>");
    $("#msgTypeBox").val("").css("height", "auto");
  }
});

$("#msgTypeBox").on("keyup", function() {
  if($(this).val() == "") {
    $(".mdi-send").addClass("disabled"); 
  } else {
    $(".mdi-send").removeClass("disabled");
  }    
});

var textarea = document.querySelector("#msgTypeBox");
textarea.addEventListener("keydown", autosize); 
function autosize() {
  var el = this;  
  setTimeout(function() {    
    el.style.cssText = "height:auto;";
    // for box-sizing other than "content-box" use:
    // el.style.cssText = '-moz-box-sizing:content-box';
    el.style.cssText = "height:" + el.scrollHeight + "px";     
  }, 0);
}
              
            
!
999px

Console