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.
<center>
<div class="device device-iphone">
<!-- Your Mockup Here! -->
<img src="https://picsum.photos/375/812">
</div>
</center>
// By: J.T. Brown
// Frontend Developer and UX/UI Designer
// EpogeeDesign.com
// Twitter: twitter.com/epogeedesign
:root {
--color-light: 255,255,255;
--color-dark: 0,0,0;
}
html {
@media (max-width:580px) {
font-size:calc((16 / 580) * 100vw);
}
}
*,*:before,*:after { box-sizing:border-box; }
.device-iphone {
//Phone Size:
font-size:100%;
@media (max-height:950px) { font-size:90%; }
@media (max-height:850px) { font-size:80%; }
@media (max-height:750px) { font-size:70%; }
@media (max-height:650px) { font-size:60%; }
@media (max-height:550px) { font-size:50%; }
@media (max-height:350px) { font-size:40%; }
position:relative;
width:375 / 16em;
height:812 / 16em;
//PHONE BODY
border-radius:60 / 16em;
padding:15 / 16em;
box-sizing:content-box;
background:rgba(var(--color-dark),1);
box-shadow:
0 2 / 16em 2 / 16em 3 / 16em rgba(var(--color-dark),1),
0 -1 / 16em 4 / 16em 3 / 16em rgba(var(--color-light),.55),
0 -1 / 16em 4 / 16em 3 / 16em rgba(var(--color-dark),1),
0 0 0 8 / 16em rgba(var(--color-light),.11),
0 0 0 8 / 16em rgba(var(--color-dark),1),
inset 0 -3 / 16em 5 / 16em 0 rgba(var(--color-light),.1),
inset 0 -3 / 16em 5 / 16em 0 rgba(var(--color-dark),1),
inset 0 -5 / 16em 2 / 16em 4 / 16em rgba(var(--color-dark),.77),
inset 0 -5 / 16em 1 / 16em 0 rgba(var(--color-light),.18),
inset 0 0 / 16em 10 / 16em 3 / 16em rgba(var(--color-dark),.87),
inset 0 5 / 16em 1 / 16em 0 rgba(var(--color-light),.18),
inset 0 -1 / 16em 5 / 16em 5 / 16em rgba(var(--color-light),.5),
0 0 20 / 16em 10 / 16em fade(black,30), //Iphone Drop Shadow
;
//BUTTONS
&:after {
content:'';
position:absolute;
width:calc(100% + .625em + .625em + .625em);
height:calc(100% + .625em + .625em + .625em);
left:-12 / 16em;
top:-12 / 16em;
filter: drop-shadow(-1px 0px 1px rgba(0,0,0,.3));
background-repeat:no-repeat;
background-image:
linear-gradient(to right, #454545, #979797, #555555 80%, #484848), // Btn- Body
radial-gradient(circle at top right, #3c3c3c 10%, #808080, #6d6d6d 54%, transparent 70%, transparent 100%), //Btn - Bottom curve
radial-gradient(circle at bottom right, #3c3c3c 10%, #808080, #6d6d6d 54%, transparent 70%, transparent 100%), // Btn - Top curve
linear-gradient(to right, #454545, #979797, #555555 80%, #484848), // Btn- Body
radial-gradient(circle at top right, #3c3c3c 10%, #808080, #6d6d6d 54%, transparent 70%, transparent 100%), //Btn - Bottom curve
radial-gradient(circle at bottom right, #3c3c3c 10%, #808080, #6d6d6d 54%, transparent 70%, transparent 100%), // Btn - Top curve
linear-gradient(to right, #454545, #979797, #555555 80%, #484848), // Btn- Body
radial-gradient(circle at top right, #3c3c3c 10%, #808080, #6d6d6d 54%, transparent 70%, transparent 100%), //Btn - Bottom curve
radial-gradient(circle at bottom right, #3c3c3c 10%, #808080, #6d6d6d 54%, transparent 70%, transparent 100%) // Btn - Top curve
;
--btn-offset:0;
--btn-width: 5px;
z-index:-1;
background-size:
var(--btn-width) 25 / 16em,
var(--btn-width) 5 / 16em,
var(--btn-width) 5 / 16em,
var(--btn-width) 60 / 16em,
var(--btn-width) 5 / 16em,
var(--btn-width) 5 / 16em,
var(--btn-width) 60 / 16em,
var(--btn-width) 5 / 16em,
var(--btn-width) 5 / 16em
;
background-position:
var(--btn-offset) 13%,
var(--btn-offset) calc(13% + 1.375em),
var(--btn-offset) calc(13% - .5em),
var(--btn-offset) 21%,
var(--btn-offset) calc(21% + 3.0625em),
var(--btn-offset) calc(21% - 1em),
var(--btn-offset) 32%,
var(--btn-offset) calc(32% + 2.5625em),
var(--btn-offset) calc(32% - 1.375em)
;
}
//BEZEL
&:before {
--sml-curve: .5em;
--big-curve: 1.375em;
--tot-height: calc(var(--sml-curve) + var(--big-curve));
--spkr-height: .375em;
--cam-height:1em;
content:'';
position:absolute;
z-index:1;
width:230 / 16em;
height:var(--tot-height);
left:50%;
transform:translateX(-50%);
filter: drop-shadow(0px .0625em .0625em fade(white,10));
background-repeat:no-repeat;
background-image:
linear-gradient(to right,#161616,#161616), // Speaker
linear-gradient(to right,#282828,#282828), // Speaker
radial-gradient(circle, fade(white,5) 40%, transparent 80%), // Camera - Glare (White)
radial-gradient(circle, #192940 40%, transparent 60%), // Camera - Glare (Blue)
radial-gradient(circle, #161616 50%, transparent 50%), // Camera - Shape
linear-gradient(to right,black,black), // Top black rectangle
radial-gradient(circle at bottom right, transparent 0, transparent 70%, black 70%, black 100%), //Right curve
radial-gradient(circle at bottom left, transparent 0, transparent 70%, black 70%, black 100%), //Left Curve
radial-gradient(circle at top right, black 0, black 70%, transparent 70%, transparent 100%), //left Curve
radial-gradient(circle at top left, black 0, black 70%, transparent 70%, transparent 100%), //Right Curve
linear-gradient(to right,black,black) // Bottom black rectangle
;
background-size:
3.75em var(--spkr-height),
3.75em var(--spkr-height),
calc(var(--cam-height) * .3) calc(var(--cam-height) * .3),
calc(var(--cam-height) * .66) calc(var(--cam-height) * .66),
var(--cam-height) var(--cam-height),
calc(100% - (var(--sml-curve) + var(--sml-curve))) calc(100% - var(--big-curve)), // Top black rectangle
var(--sml-curve) var(--sml-curve), //Right curve
var(--sml-curve) var(--sml-curve), //Left Curve
var(--big-curve) var(--big-curve), //Left Curve
var(--big-curve) var(--big-curve), //Right Curve
calc(102% - (var(--sml-curve) + var(--sml-curve) + var(--big-curve) + var(--big-curve))) 100% // Bottom black rectangle
;
background-position:
50% calc(50% - (var(--spkr-height) * .5)),
50% calc(50% - (-1px + (var(--spkr-height) * .5))),
calc(70% - .1875em) calc(25% + .0625em),
calc(70% - .125em) calc(25% + .0625em),
70% 25%,
var(--sml-curve) 0, // Top black rectangle
100% 0, //Right curve
0% 0, //Left Curve
var(--sml-curve) calc((var(--sml-curve) )), //Left Curve
calc(100% - var(--sml-curve)) calc((var(--sml-curve) )), //Right Curve
calc(var(--sml-curve) + var(--big-curve) - 1px) 0, // Bottom black rectangle
;
}
img {
width:100%;
height:auto;
display:block;
max-width:375px;
height:auto;
border-radius:45 / 16em;
}
}
//FOR USE IN CODEPEN ONLY, Not needed for project.
//Animated BG Credit: https://codepen.io/P1N2O/pen/pyBNzX
body, html { height:100%;overflow:hidden; }
body {
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
background-size: 400% 400%;
animation: gradient 15s ease infinite;
}
@keyframes gradient {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
center {
display:flex;
align-items:center;
justify-content:center;
height:100%;
width:100%;
text-align:left;
margin:0 auto;
box-sizing:border-box;
}
Also see: Tab Triggers