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="info-panel">
<div class="info-title">
<h1>Chat Widget</h1>
<h2> <a target="_new" href="https://www.andrewhaine.co.uk">Andrew Haine</a></h2>
</div>
</div>
<div class="phone-canvas">
<div class="chat-ui-canvas">
<div id="header" class="header header-scrolled">
<div class="top-icons">
<div class="back-arrow">
<div class="back-arrow-line back-arrow-line-1"></div>
<div class="back-arrow-line back-arrow-line-2"></div>
<div class="back-arrow-line back-arrow-line-3"></div>
</div>
<div class="phone-icon">
<img src="https://i.imgur.com/4OTkocV.png" height="50%">
</div>
</div>
<div class="user-header-image"></div>
<div class="user-name-header"><h1>Arthur Johnson</h1></div>
</div>
<div id="message-feed" class="message-feed message-feed-unscrolled">
<div class="message message-from">
<div class="message-name"><h1>Arthur</h1></div>
<div class="message-body">
<p>
Put a bird on it wolf gentrify retro forage freegan craft beer ramps, mlkshk cold-pressed listicle before they sold out +1 slow-carb.
</p>
</div>
<div class="message-timestamp">
<p>Today 10:02</p>
</div>
</div>
<div class="message message-to">
<div class="message-name"><h1>You</h1></div>
<div class="message-body">
<p>
Tumblr meh chartreuse, messenger bag hammock heirloom bicycle rights pour-over fingerstache. Next level selfies kickstarter, vice gentrify pinterest whatever heirloom occupy ramps direct trade celiac +1.
</p>
</div>
<div class="message-timestamp">
<p>Today 10:14</p>
</div>
</div>
<div class="message message-from">
<div class="message-name"><h1>Arthur</h1></div>
<div class="message-body">
<p>
Viral portland thundercats readymade wayfarers man bun. Bespoke semiotics vegan, chia asymmetrical shabby chic quinoa man braid wayfarers
</p>
</div>
<div class="message-timestamp">
<p>Today 10:20</p>
</div>
</div>
</div>
<div class="message-input-bar">
<div id="media-expand-arrow" class="media-expand-arrow">
<div class="media-expand-arrow-line media-expand-arrow-line-1"></div>
<div class="media-expand-arrow-line media-expand-arrow-line-2"></div>
<div class="media-expand-arrow-line media-expand-arrow-line-3"></div>
</div>
<div class="message-text-input">
<form class="message-send">
<textarea id="message-input" placeholder="Message..." value=""></textarea>
</form>
</div>
</div>
<div id="media-bar" class="media-bar">
<div class="media-bar-header">
<div class="media-bar-title"> <h1>Media</h1>
</div>
<div id="media-bar-cross" class="media-close">
<div class="media-close-line media-close-line-1"></div>
<div class="media-close-line media-close-line-2"></div>
</div>
</div>
<div class="media-bar-body">
<div class="media-buttons-canvas">
<div class="media-button media-video">
<img src="https://imgur.com/x9NDjYV.png">
</div>
<div class="media-button media-image">
<img src="https://imgur.com/0Sw4F6i.png">
</div>
<div class="media-button media-audio">
<img src="https://imgur.com/2KlzOiN.png">
</div>
<div class="media-button media-location">
<img src="https://imgur.com/OvqVDk5.png">
</div>
</div>
</div>
</div>
</div>
</div>
@charset "utf-8"
@import url(https://fonts.googleapis.com/css?family=Lato:200,300,400,100,700)
@import url(https://fonts.googleapis.com/css?family=Bubblegum+Sans)
/*Font in PSD is Open Sans, I had to use Lato in order to get the desired font-weight for the header.
/* any elements with a commented out background color can be un-commented to see the guides
$bodyBack: rgb(51, 102, 153)
body
position: relative
overflow-x: hidden
background-color: darken($bodyBack, 5%)
.info-panel *
font-family: 'Bubblegum Sans', cursive
color: white
font-weight: 200
.info-panel
position: relative
float: left
padding-left: 5%
padding-top: 2%
width: 30%
.info-title
h1
font-size: 4em
.phone-canvas
position: relative
margin: 0 auto
width: 25vw
height: 44.5vw
min-width: 500px
min-height: 889px
.chat-ui-canvas
position: relative
margin: 0 auto
width: 19vw
height: 33.5vw
min-width: 340px
min-height: 604px
background-image: url("https://i.imgur.com/eKHNpIu.png")
background-size: cover
overflow: hidden
top: 3vw
border: 8px white solid
border-radius: 20px
box-shadow: 3px 3px 3px
.header
outline: white 3px solid
position: relative
top: 0px
.header.header-unscrolled
height: 39%
transition: height 0.5s ease-in-out
.top-icons
height: 23%
width: 100%
position: relative
top: 3%
padding: 0px
transition: height 0.5s ease-in-out
.back-arrow
position: relative
display: inline-block
height: 100%
width: 20%
padding: 0px
cursor: pointer
.back-arrow-line
transition: all 0.1s ease-in-out
position: absolute
width: 5%
background-color: #ffffff
padding: 0px
.back-arrow-line-1
transform: rotate(50deg)
left: 32%
top: 21.8%
height: 30%
.back-arrow-line-2
transform: rotate(-50deg)
left: 32%
height: 30%
top: 37.5%
.back-arrow-line-3
left: 48%
top: 20%
transform: rotate(90deg)
height: 50%
&:hover
.back-arrow-line-1
left: 25%
.back-arrow-line-2
left: 25%
.back-arrow-line-3
left: 40%
.phone-icon
height: 100%
width: 20%
position: relative
left: 60%
display: inline-block
cursor: pointer
opacity: 1
transition: opacity 0.2s ease-in-out
img
position: absolute
margin: 0 auto
top: 20%
left: 25%
transition: all 0.1s ease-in-out
&:hover
img
transform: scale(1.1)
.user-header-image
width: 31%
opacity: 1
transition: opacity 0.3s ease-in-out
transition-delay: 0.3s
background-image: url("https://i.imgur.com/Tl5p1Wb.png")
background-size: cover
top: -5%
height: 45%
position: relative
margin: 0 auto
border: 4px white solid
border-radius: 100%
overflow: hidden
box-shadow: 1px 1px 5px #3c3c3c
.user-name-header
position: relative
width: 100%
bottom: 5%
top: -7%
transition: top 0.5s ease-in-out
transition-delay: 0.1s
h1
text-align: center
font-family: 'Lato', sans-serif
font-weight: 300
color: white
font-size: 2.5em
transition: all 0.5s ease-in-out
.header.header-scrolled
height: 13%
transition: height 0.5s ease-in-out
.top-icons
height: 69%
transition: height 0.5s ease-in-out
transition-delay: 0.1s
width: 100%
position: relative
top: 3%
padding: 0px
.back-arrow
position: relative
display: inline-block
height: 100%
width: 20%
top: 27%
padding: 0px
cursor: pointer
.back-arrow-line
transition: all 0.1s ease-in-out
position: absolute
width: 5%
background-color: #ffffff
padding: 0px
.back-arrow-line-1
transform: rotate(50deg)
left: 32%
top: 21.8%
height: 30%
.back-arrow-line-2
transform: rotate(-50deg)
left: 32%
height: 30%
top: 37.5%
.back-arrow-line-3
left: 48%
top: 20%
transform: rotate(90deg)
height: 50%
&:hover
.back-arrow-line-1
left: 25%
.back-arrow-line-2
left: 25%
.back-arrow-line-3
left: 40%
.phone-icon
height: 100%
width: 20%
position: relative
left: 60%
display: inline-block
cursor: pointer
opacity: 0
transition: opacity 0.2s ease-in-out
img
position: absolute
margin: 0 auto
top: 20%
left: 25%
transition: all 0.1s ease-in-out
&:hover
img
transform: scale(1.1)
.user-header-image
opacity: 0
transition: opacity 0.3s ease-in-out
.user-name-header
position: relative
width: 100%
bottom: 5%
top: -65%
transition: top 0.6s ease-in-out
transition-delay: 0.1s
h1
text-align: center
font-family: 'Lato', sans-serif
font-weight: 300
color: white
font-size: 2em
transition: all 0.5s ease-in-out
.message-feed.message-feed-scrolled
height: 77% !important
.message-feed::-webkit-scrollbar
//background-color: green
background-color: transparent
width: 2%
.message-feed::-webkit-scrollbar-thumb
background-color: transparent
border-radius: 80px
transition: background-color 0.2s ease-in-out
.message-feed:hover::-webkit-scrollbar-thumb
background-color: #868686
transition: background-color 0.2s ease-in-out
.message-feed
position: relative
width: 100%
bottom: 0px !important
height: 51%
overflow-y: scroll
overflow-x: hidden
.message *
margin: 0 auto
.message
margin-left: 2%
position: relative
width: 90%
border-bottom: 1px white solid
padding: 1%
padding-left: 5%
padding-right: 5%
display: block
.message-name
position: relative
width: 95%
padding: 0px
top: 0px
display: block
h1
font-family: 'Lato', sans-serif
color: white
font-weight: 700
font-size: 1.4em
height: 100%
margin: 1%
margin-top: 3%
.message-body
position: relative
width: 80%
top: 0px
display: block
word-break: break-all
p
font-family: 'Lato', sans-serif
color: white
font-weight: 300
font-size: 0.8em
margin: 1%
.message-timestamp
position: relative
width: 95%
top: 0px
display: block
p
font-family: 'Lato', sans-serif
color: white
font-weight: 700
font-size: 0.7em
margin: 1%
margin-top: 3%
margin-bottom: 3%
.message.message-to *
text-align: right
margin-right: 0px
.message.message-from *
margin-left: 0px
.message-input-bar
position: absolute
z-index: 3
background: rgba(0, 0, 0, 0.3)
outline: white 3px solid
width: 100%
height: 10%
bottom: 0px !important
box-sizing: border-box
margin: 0px
.media-expand-arrow
position: absolute
display: inline-block
width: 20%
height: 100%
top: 0px
//background-color: green
cursor: pointer
.media-expand-arrow-line
transition: all 0.1s ease-in-out
position: absolute
width: 5%
background-color: #ffffff
padding: 0px
transition: all 0.1s ease-in-out
.media-expand-arrow-line-1
transform: rotate(50deg)
left: 39%
top: 16%
height: 25%
.media-expand-arrow-line-2
transform: rotate(-50deg)
left: 52%
height: 25%
top: 16%
.media-expand-arrow-line-3
left: 45.3%
top: 20.5%
height: 46%
&:hover
.media-expand-arrow-line-1
top: 10%
.media-expand-arrow-line-2
top: 10%
.media-expand-arrow-line-3
top: 15%
.message-text-input
display: inline-block
//background-color: red
box-sizing: border-box
margin: 0px
position: absolute
width: 80%
height: 100%
right: 0px
form
width: 100%
height: 100%
position: relative
textarea
position: relative
margin: 0 auto
width: 90%
height: 40%
left: 0%
top: 17%
font-size: 1.2em
font-family: "lato", sans-serif
padding-left: 2%
overflowY: scroll
resize: none
border-radius: 0px !important
.media-bar
position: relative
background-color: #e8e8e8
width: 100%
top: 100%
height: 25%
z-index: 4
transition: all 0.4s ease-in-out
.media-bar-header
width: 100%
height: 30%
position: relative
background-color: #363636
.media-bar-title
position: relative
width: 40%
//background-color: red
height: 100%
padding-left: 3%
h1
font-family: 'Lato', sans-serif
color: white
font-size: 2em
line-height: 1.3em
font-weight: 300
padding-left: 6%
.media-close
//background-color: green
position: relative
height: 100%
width: 17%
top: -100%
left: 83%
cursor: pointer
.media-close-line
position: absolute
background-color: #ffffff
width: 6%
height: 75%
top: 10%
transition: all 0.2s ease-in-out
.media-close-line-1
transform: rotate(45deg)
left: 50%
.media-close-line-2
transform: rotate(-45deg)
left: 50%
&:hover
.media-close-line
height: 90%
top: 0
transition: all 0.2s ease-in-out
.media-bar-body
position: relative
width: 100%
height: 70%
top: 0%
//background-color: blue
.media-buttons-canvas
height: 80%
top: 10%
width: 95%
margin: 0 auto
position: relative
//background-color: brown
padding: 0px
.media-button
width: 25%
position: relative
height: 100%
display: block
padding: 0px
float: left
cursor: pointer
img
width: 90%
left: 5%
top: 5%
position: relative
filter: grayscale(100%)
-webkit-filter: grayscale(100%)
transition: all 0.3s ease-in-out
&:hover
filter: grayscale(0%)
-webkit-filter: grayscale(0%)
transition: all 0.3s ease-in-out
.media-button.media-audio
img
filter: brightness(150%)
-webkit-filter: grayscale(100%) brightness(150%)
&:hover
filter: brightness(150%)
-webkit-filter: grayscale(0%)
.media-bar.media-bar-open
top: -17.6% !important
transition: top 0.5s ease-in-out
window.onload = function () {
var mediaExpand = document.getElementById("media-expand-arrow");
var mediaBar = document.getElementById("media-bar");
var mediaCross = document.getElementById("media-bar-cross");
var messageFeed = document.getElementById("message-feed");
console.log(mediaExpand + mediaBar);
function mediaOpen(){
mediaBar.className += " media-bar-open"
};
mediaExpand.addEventListener("click", mediaOpen, false);
function mediaClose(){
mediaBar.className = "media-bar"
};
mediaCross.addEventListener("click", mediaClose, false);
function wScroll(){
console.log(messageFeed.scrollTop);
messageHeight = messageFeed.offsetHeight;
var heightToScroll = (130);
var header = document.getElementById('header');
if(messageFeed.scrollTop > heightToScroll){
header.className = "header header-scrolled"
messageFeed.className = "message-feed message-feed-scrolled"
}
else if(messageFeed.scrollTop < 1){
header.className = "header header-unscrolled"
messageFeed.className = "message-feed"
}
};
messageFeed.addEventListener("scroll", wScroll, false);
wScroll();
function logMessage(event){
//get time
function addZero(i){
if(i < 10){
i = "0" + i
}
return i;
}
var d = new Date();
var h = addZero(d.getHours());
var m = addZero(d.getMinutes());
//build message
function appendMessage() {
$('#message-feed').append(
'<div class="message message-to"><div class="message-name"><h1>You</h1></div><div class="message-body"><p>' + messageVal + '</p></div><div class="message-timestamp"><p>Today ' + h + ' : ' + m + '</p></div>'
);
}
//set event trigger
var messageInput = document.getElementById("message-input");
var messageVal = messageInput.value;
//hipsum responses
var responseTimed;
function timedResponse(){
setTimeout(
function appendResponse() {
var randNumber = Math.floor((Math.random()*10)+1)
switch(randNumber){
case 1:
$('#message-feed').append(
'<div class="message message-from"><div class="message-name"><h1>Arthur</h1></div><div class="message-body"><p>Gluten-free VHS gentrify, humblebrag blue bottle retro vegan yuccie swag etsy.</p></div><div class="message-timestamp"><p>Today ' + h + ' : ' + m + '</p></div>'
);
break;
case 2:
$('#message-feed').append(
'<div class="message message-from"><div class="message-name"><h1>Arthur</h1></div><div class="message-body"><p>Tilde ethical offal plaid everyday carry meggings banjo gentrify, green juice food truck fap. Beard lumbersexual photo booth.</p></div><div class="message-timestamp"><p>Today ' + h + ' : ' + m + '</p></div>'
);
break;
case 3:
$('#message-feed').append(
'<div class="message message-from"><div class="message-name"><h1>Arthur</h1></div><div class="message-body"><p>Cliche sriracha jean shorts, cronut beard irony meh asymmetrical man braid offal.</p></div><div class="message-timestamp"><p>Today ' + h + ' : ' + m + '</p></div>'
);
break;
case 4:
$('#message-feed').append(
'<div class="message message-from"><div class="message-name"><h1>Arthur</h1></div><div class="message-body"><p>Quinoa man braid tumblr venmo lomo cray microdosing, pinterest celiac affogato fingerstache umami fashion axe schlitz. Ethical four loko truffaut salvia.</p></div><div class="message-timestamp"><p>Today ' + h + ' : ' + m + '</p></div>'
);
break;
case 5:
$('#message-feed').append(
'<div class="message message-from"><div class="message-name"><h1>Arthur</h1></div><div class="message-body"><p>Street art bicycle rights letterpress mixtape cold-pressed. Drinking vinegar flexitarian quinoa twee.</p></div><div class="message-timestamp"><p>Today ' + h + ' : ' + m + '</p></div>'
);
break;
case 6:
$('#message-feed').append(
'<div class="message message-from"><div class="message-name"><h1>Arthur</h1></div><div class="message-body"><p> Artisan heirloom iPhone normcore, salvia farm-to-table vice freegan hammock waistcoat.</p></div><div class="message-timestamp"><p>Today ' + h + ' : ' + m + '</p></div>'
);
break;
case 7:
$('#message-feed').append(
'<div class="message message-from"><div class="message-name"><h1>Arthur</h1></div><div class="message-body"><p>Pinterest kale chips single-origin coffee, man braid franzen ethical chia plaid locavore small batch hashtag swag. Dreamcatcher kogi fingerstache, lo-fi roof party pork belly.</p></div><div class="message-timestamp"><p>Today ' + h + ' : ' + m + '</p></div>'
);
break;
case 8:
$('#message-feed').append(
'<div class="message message-from"><div class="message-name"><h1>Arthur</h1></div><div class="message-body"><p> Vegan celiac heirloom knausgaard. Paleo mixtape ramps irony lomo.</p></div><div class="message-timestamp"><p>Today ' + h + ' : ' + m + '</p></div>'
);
break;
}
messageFeed.scrollTop = messageFeed.scrollHeight;
}, 2500);
};
//fire on enter
if (event.keyCode == 13) {
event.preventDefault();
messageInput.value= "";
appendMessage();
messageFeed.scrollTop = messageFeed.scrollHeight;
timedResponse();
}
};
document.addEventListener("keypress", logMessage, false);
}
Also see: Tab Triggers