HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<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>
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;
}
/*
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 : hi@vatanay.com
*/
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) {
$('.responsive-html5-chat').find('.messages').scrollTop($('.responsive-html5-chat .messages')[0].scrollHeight);
}
showLatestMessage(element);
$(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(element);
});
}
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();
}
Also see: Tab Triggers