I create Apple's iOS9 iMessage front-end development with HTML, CSS and jQuery. It's completely responsive. Enjoy!
http://www.adobewordpress.com/iphone-mesajlar-ekrani
A Pen by adobewordpress on CodePen.
<div class="iphone"> | |
<div class="border"> | |
<div class="responsive-html5-chat"> | |
</div> | |
</div> | |
</div> | |
<!-- DEMO --> | |
<a href="http://www.adobewordpress.com/iphone-mesajlar-ekrani" target="_blank" class="article" style="display:none">Read Article</a> |
I create Apple's iOS9 iMessage front-end development with HTML, CSS and jQuery. It's completely responsive. Enjoy!
http://www.adobewordpress.com/iphone-mesajlar-ekrani
A Pen by adobewordpress on CodePen.
/* | |
Name : Responsive HTML5 Chat | |
Responsive HTML5 Chat helps you to create useful chatbox on your website easly. | |
You can change skin and sizes. You can read the installation and support documentation | |
before you begin. If you do not find the answer, do not hesitate to send a message to me. | |
Owner : Vatanay Ozbeyli | |
Web : www.vatanay.com | |
Support : [email protected] | |
*/ | |
function responsiveChat(element) { | |
$(element).html('<form class="chat"><span></span><div class="messages"></div><input type="text" placeholder="Your message"><input type="submit" value="Send"></form>'); | |
function showLatestMessage() { | |
$(element).find('.messages').scrollTop($(element).find('.messages').height()); | |
} | |
showLatestMessage(); | |
$(element + ' input[type="text"]').keypress(function (event) { | |
if (event.which == 13) { | |
event.preventDefault(); | |
$(element + ' input[type="submit"]').click(); | |
} | |
}); | |
$(element + ' input[type="submit"]').click(function (event) { | |
event.preventDefault(); | |
var message = $(element + ' input[type="text"]').val(); | |
if ($(element + ' input[type="text"]').val()) { | |
var d = new Date(); | |
var clock = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds(); | |
var month = d.getMonth() + 1; | |
var day = d.getDate(); | |
var currentDate = | |
(("" + day).length < 2 ? "0" : "") + | |
day + | |
"." + | |
(("" + month).length < 2 ? "0" : "") + | |
month + | |
"." + | |
d.getFullYear() + | |
" " + | |
clock; | |
$(element + ' div.messages').append( | |
'<div class="message"><div class="myMessage"><p>' + | |
message + | |
"</p><date>" + | |
currentDate + | |
"</date></div></div>" | |
); | |
setTimeout(function () { | |
$(element + ' > span').addClass("spinner"); | |
}, 100); | |
setTimeout(function () { | |
$(element + ' > span').removeClass("spinner"); | |
}, 2000); | |
} | |
$(element + ' input[type="text"]').val(""); | |
showLatestMessage(); | |
}); | |
} | |
function responsiveChatPush(element, sender, origin, date, message) { | |
var originClass; | |
if (origin == 'me') { | |
originClass = 'myMessage'; | |
} else { | |
originClass = 'fromThem'; | |
} | |
$(element + ' .messages').append('<div class="message"><div class="' + originClass + '"><p>' + message + '</p><date><b>' + sender + '</b> ' + date + '</date></div></div>'); | |
} | |
/* Activating chatbox on element */ | |
responsiveChat('.responsive-html5-chat'); | |
/* Let's push some dummy data */ | |
responsiveChatPush('.chat', 'Kate', 'me', '08.03.2017 14:30:7', 'It looks beautiful!'); | |
responsiveChatPush('.chat', 'John Doe', 'you', '08.03.2016 14:31:22', 'It looks like the iPhone message box.'); | |
responsiveChatPush('.chat', 'Kate', 'me', '08.03.2016 14:33:32', 'Yep, is this design responsive?'); | |
responsiveChatPush('.chat', 'Kate', 'me', '08.03.2016 14:36:4', 'By the way when I hover on my message it shows date.'); | |
responsiveChatPush('.chat', 'John Doe', 'you', '08.03.2016 14:37:12', 'Yes, this is completely responsive.'); | |
/* DEMO */ | |
if (parent == top) { | |
$("a.article").show(); | |
} |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
form.chat *{ | |
transition:all .5s; | |
box-sizing:border-box; | |
-webkit-box-sizing:border-box; | |
-moz-box-sizing:border-box; | |
} | |
form.chat { | |
margin:0; | |
cursor:default; | |
position:absolute; | |
left:0; | |
right:0; | |
bottom:0; | |
top:0; | |
-webkit-touch-callout: none; /* iOS Safari */ | |
-webkit-user-select: none; /* Chrome/Safari/Opera */ | |
-khtml-user-select: none; /* Konqueror */ | |
-moz-user-select: none; /* Firefox */ | |
-ms-user-select: none; /* IE/Edge */ | |
user-select: none; | |
} | |
form.chat span.spinner{ | |
-moz-animation: loading-bar 1s 1; | |
-webkit-animation: loading-bar 1s 1; | |
animation: loading-bar 1s 1; | |
display: block; | |
height: 2px; | |
background-color: #00e34d; | |
transition: width 0.2s; | |
position:absolute; | |
top:0; left:0; right:0; | |
z-index:4 | |
} | |
form.chat .messages{ | |
display:block; | |
overflow-x: hidden; | |
overflow-y: scroll; | |
position:relative; | |
height:90%; | |
width:100%; | |
padding:2% 3%; | |
border-bottom:1px solid #ecf0f1; | |
} | |
form.chat ::-webkit-scrollbar {width: 3px; height:1px;transition:all .5s;z-index:10;} | |
form.chat ::-webkit-scrollbar-track {background-color: white;} | |
form.chat ::-webkit-scrollbar-thumb { | |
background-color: #bec4c8; | |
border-radius:3px; | |
} | |
form.chat .message{ | |
display:block; | |
width:98%; | |
padding:0.5%; | |
} | |
form.chat .message p{ | |
margin:0; | |
} | |
form.chat .myMessage, | |
form.chat .fromThem { | |
max-width: 50%; | |
word-wrap: break-word; | |
margin-bottom: 20px; | |
} | |
form.chat .message:hover .myMessage{ | |
-webkit-transform: translateX(-130px); | |
transform: translateX(-130px); | |
} | |
form.chat .message:hover .fromThem{ | |
-webkit-transform: translateX(130px); | |
transform: translateX(130px); | |
} | |
form.chat .message:hover date { | |
opacity: 1; | |
} | |
form.chat .myMessage,.fromThem{ | |
position: relative; | |
padding: 10px 20px; | |
color: white; | |
border-radius: 25px; | |
clear: both; | |
font: 400 15px 'Open Sans', sans-serif; | |
} | |
form.chat .myMessage { | |
background: #00e34d; | |
color:white; | |
float:right; | |
clear:both; | |
border-bottom-right-radius: 20px 0px\9; | |
} | |
form.chat .myMessage:before { | |
content: ""; | |
position: absolute; | |
z-index: 1; | |
bottom: -2px; | |
right: -8px; | |
height: 19px; | |
border-right: 20px solid #00e34d; | |
border-bottom-left-radius: 16px 14px; | |
-webkit-transform: translate(0, -2px); | |
transform: translate(0, -2px); | |
border-bottom-left-radius: 15px 0px\9; | |
transform: translate(-1px, -2px)\9; | |
} | |
form.chat .myMessage:after { | |
content: ""; | |
position: absolute; | |
z-index: 1; | |
bottom: -2px; | |
right: -42px; | |
width: 12px; | |
height: 20px; | |
background: white; | |
border-bottom-left-radius: 10px; | |
-webkit-transform: translate(-30px, -2px); | |
transform: translate(-30px, -2px); | |
} | |
form.chat .fromThem { | |
background: #E5E5EA; | |
color: black; | |
float: left; | |
clear:both; | |
border-bottom-left-radius: 30px 0px\9; | |
} | |
form.chat .fromThem:before { | |
content: ""; | |
position: absolute; | |
z-index: 2; | |
bottom: -2px; | |
left: -7px; | |
height: 19px; | |
border-left: 20px solid #E5E5EA; | |
border-bottom-right-radius: 16px 14px; | |
-webkit-transform: translate(0, -2px); | |
transform: translate(0, -2px); | |
border-bottom-right-radius: 15px 0px\9; | |
transform: translate(-1px, -2px)\9; | |
} | |
form.chat .fromThem:after { | |
content: ""; | |
position: absolute; | |
z-index: 3; | |
bottom: -2px; | |
left: 4px; | |
width: 26px; | |
height: 20px; | |
background: white; | |
border-bottom-right-radius: 10px; | |
-webkit-transform: translate(-30px, -2px); | |
transform: translate(-30px, -2px); | |
} | |
form.chat date { | |
position:absolute; | |
top: 10px; | |
font-size:14px; | |
white-space:nowrap; | |
vertical-align:middle; | |
color: #8b8b90; | |
opacity: 0; | |
z-index:4; | |
} | |
form.chat .myMessage date { | |
left: 105%; | |
} | |
form.chat .fromThem date { | |
right: 105%; | |
} | |
form.chat input{ | |
font: 400 13px 'Open Sans', sans-serif; | |
border:0; | |
padding:0 15px; | |
height:10%; | |
outline:0; | |
} | |
form.chat input[type='text']{ | |
width:73%; | |
float:left; | |
} | |
form.chat input[type='submit']{ | |
width:23%; | |
background:transparent; | |
color:#00E34D; | |
font-weight:700; | |
text-align:right; | |
float:right; | |
} | |
form.chat .myMessage,form.chat .fromThem{ | |
font-size:12px; | |
} | |
form.chat .message:hover .myMessage{ | |
transform: translateY(18px); | |
-webkit-transform: translateY(18px); | |
} | |
form.chat .message:hover .fromThem{ | |
transform: translateY(18px); | |
-webkit-transform: translateY(18px); | |
} | |
form.chat .myMessage date,form.chat .fromThem date { | |
top: -20px; | |
left:auto; | |
right:0; | |
font-size:12px; | |
} | |
form.chat .myMessage, | |
form.chat .fromThem { | |
max-width: 90%; | |
} | |
@-moz-keyframes loading-bar { | |
0% { | |
width: 0%; | |
} | |
90% { | |
width: 90%; | |
} | |
100% { | |
width: 100%; | |
} | |
} | |
@-webkit-keyframes loading-bar { | |
0% { | |
width: 0%; | |
} | |
90% { | |
width: 90%; | |
} | |
100% { | |
width: 100%; | |
} | |
} | |
@keyframes loading-bar { | |
0% { | |
width: 0%; | |
} | |
90% { | |
width: 90%; | |
} | |
100% { | |
width: 100%; | |
} | |
} | |
/* DEMO */ | |
.iphone{ | |
width:300px; | |
height:609px; | |
background-image:url('http://www.adobewordpress.com/tasarim/images/iphone6.png'); | |
background-size:100% 100%; | |
margin:0 auto; | |
position:relative; | |
} | |
.border{ | |
position:absolute; | |
top:12.3%;right:7%;left:7%;bottom:12%; | |
overflow:hidden; | |
} | |
a.article{ | |
position:fixed; | |
bottom:15px;left:15px; | |
display:table; | |
text-decoration:none; | |
color:white; | |
background-color:#00e34d; | |
padding: 10px 20px; | |
border-radius: 25px; | |
font: 400 15px 'Open Sans', sans-serif; | |
} |