Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                //- Daily UI #013 Direct Messaging

.chat
	.chat-title
		h2 Kelly Chen
		figure.avatar: img(src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/764024/profile/profile-512.jpg")
	.messages
		.messages-content
	.action-box
		textarea.action-box-input(type="text" placeholder="Type message...")
		button.action-box-submit(type="submit" onclick="insertMessage()"): i.fa.fa-paper-plane
              
            
!

CSS

              
                @mixin size($w, $h)
	width: $w
	height: $h
@mixin bdrs($bdrs)
	border-radius: $bdrs
%center
	position: absolute
	top: 50%
	left: 50%
	transform: translate(-50%, -50%)
%clearfix
	&::after
		content: ""
		display: block
		clear: both
@keyframes ball
	0%
		margin-top: 0
	20%
		margin-top: 3px
	80%
		margin-top: -5px
@keyframes pop
	0%
		transform: scale(.6)
	30%
		transform: scale(1.1)
	60%
		transform: scale(.9)
	100%
		transform: scale(1)
.mCSB_container
	margin: 0 !important
.mCSB_scrollTools
	margin-right: -3px
*
	outline: none
body, html
	margin: 0
	height: 100%
	width: 100%
html
	background: #bdc3c7
	background: -webkit-linear-gradient(to right bottom, #bdc3c7 , #2c3e50)
	background: linear-gradient(to right bottom, #bdc3c7 , #2c3e50)
body
	font-family: 'Microsoft JhengHei', Arial, sans-serif
	background: url('https://www.transparenttextures.com/patterns/45-degree-fabric-light.png')
	letter-spacing: 1px
	.chat
		@extend %center
		+size(300px, 80vh)
		max-height: 500px
		+bdrs(15px)
		background-color: rgba(black, .5)
		overflow: hidden
		&-title
			background-color: rgba(black, .3)
			@extend %clearfix
			+size(100%, 50px)
			h2
				margin: 10px 0
				padding: 0
				color: #f0f0f0
				font-weight: normal
				font-size: 16px
				display: inline-block
				line-height: 30px
			.avatar
				float: left
				margin: 10px
				padding: 0
				+size(30px, 30px)
				img
					+bdrs(50%)
					+size(30px, 30px)
	.messages
		+size(100%, calc(100% - 90px))
		&-content
			+size(100%, 100%)
			overflow-y: auto
			box-sizing: border-box
			.message
				max-width: calc(100% - 76px)
				padding: 8px
				margin: 8px 0 8px 12px
				+bdrs(5px)
				background-color: rgba(#abc, .1)
				color: #e3e3e3
				float: left
				font-size: 13px
				position: relative
				word-break: break-all
				clear: both
				animation: pop .3s forwards
				.timestamp
					position: absolute
					right: -40px
					bottom: 0
					font-size: 12px
					color: #bababa
				&.personal
					float: right
					margin: 8px 12px 8px 0
					.timestamp
						right: auto
						left: -40px
				&.typing
					+size(30px, 16px)
					&::after
						content: ""
						+bdrs(50%)
						+size(3px, 3px)
						background-color: white
						@extend %center
						transform: translate(-50%, -50%)
						animation: ball 1.2s infinite linear
					span
						+size(3px, 3px)
						@extend %center
						transform: translate(-50%, -50%)
						&::before, &::after
							content: ""
							+bdrs(50%)
							+size(3px, 3px)
							position: absolute
							background-color: white
							animation: ball 1.2s infinite linear
						&::before
							left: 8px
							animation-delay: .3s
						&::after
							right: 8px
							animation-delay: -.3s
	.action-box
		background-color: rgba(black, .3)
		+size(100%, 40px)
		@extend %clearfix
		&-input, &-submit
			box-sizing: border-box
			border: 0
			float: left
		&-input
			+size(calc(100% - 60px), 20px)
			background-color: transparent
			resize: none
			color: white
			margin: 10px 0
			padding: 0 10px
			line-height: 20px
			font-size: 16px
			letter-spacing: 1px
			overflow: hidden
			&::-webkit-input-placeholder
				line-height: 20px
				font-size: 13px
		&-submit
			+size(60px, 40px)
			background-color: rgba(#bdc3c7, .2)
			color: white
			cursor: pointer
			
              
            
!

JS

              
                # JS practice.
# Reference:https://codepen.io/supah/pen/jqOBqp
# It's Cool ! ↑

messages = $(".messages-content")
fakeNum = 0

isTyping = true
uctTimer = null

window.userTypingClear = ->
	uctTimer = setTimeout ->
		$(".message.personal.typing").remove()
		isTyping = true
	, 3500

window.setDate = ->
	timestamp = $("<div>").addClass "timestamp"
	d = new Date()
	timestamp.text d.getHours() + ":" + (if d.getMinutes() < 10 then '0' else '') + d.getMinutes()
	timestamp.appendTo $('.message:last')

window.updateScrollbar = ->
  messages.mCustomScrollbar("update").mCustomScrollbar 'scrollTo', 'bottom', 
    scrollInertia: 10
    timeout: 0
	
fakeMsg = [
	"Hi there, I\'m Kelly and you?"
	"Nice to meet you"
	"How are you doing?"
	"Pretty good"
	"How\'s life been treating you?"
	"It could be worse, thanks"
	"I\'ve gotta go now"
	"It was a pleasure chat with you"
	"Bye :)"
]
  
window.setFakeMessage = ->
	typing = $("<div>").append("<span>").addClass "message typing"
	typing.appendTo $('.mCSB_container')
	updateScrollbar()
	setTimeout ->
		typing.remove()
		msg = $("<div>").addClass "message"
		msg.text fakeMsg[fakeNum]
		msg.appendTo $('.mCSB_container')
		setDate()
		updateScrollbar()
		fakeNum++
	, 1000 + (Math.random() * 10) * 100

window.insertMessage = ->
	msgText =  $(".action-box-input").val()
	if $.trim(msgText) == ""
		return false
	msg = $("<div>").addClass "message"
	msg.text msgText
	msg.addClass("personal").appendTo $('.mCSB_container')
	setDate()
	updateScrollbar()
	$(".action-box-input").val(null)
	
	$(".message.personal.typing").remove()
	isTyping = true
	clearTimeout uctTimer
	
	if $.trim(fakeMsg[fakeNum]) == ""
		return false
	setTimeout ->
		setFakeMessage()
	, 500 + (Math.random() * 10) * 100

$(window).on 'keydown', (e) ->
  if (e.which == 13) 
    insertMessage()
    return false

$(window).load ->
	messages.mCustomScrollbar()
	setTimeout ->
		setFakeMessage()
	, 100
	return
	
$(".action-box-input").on "keydown", (e) ->
	if $(".action-box-input") != "" && isTyping == true && e.which != 13
		typing = $("<div>").append("<span>").addClass "message personal typing"
		typing.appendTo $('.mCSB_container')
		updateScrollbar()
		isTyping = false
		userTypingClear()


              
            
!
999px

Console