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 URL's 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 it's URL and the proper URL extention.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<canvas id="c" height="400" width="400"></canvas>
body {
padding: 0;
margin: 0;
}
canvas {
width: 100vw;
height: 100vh;
object-fit: cover;
}
let svgString = `<svg width="551pt" height="992pt" version="1.0" viewBox="0 0 551 992" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(0 992)" fill="#fff">
<path d="m5045 9891c-128-58-293-232-405-427-70-121-96-153-138-171-105-44-132-59-201-113-83-64-191-120-232-120-112 0-492-344-579-525-37-76-65-85-323-101-120-7-235-18-255-24-71-19-92-14-141 38-25 26-75 99-110 162s-65 117-67 119-50-41-106-95c-100-96-149-129-233-154-136-42-395-308-395-406 0-67-33-82-207-93-165-10-210-25-257-87-41-53-73-81-158-132-151-93-299-154-414-172-37-6-79-17-94-25-29-15-120-103-120-117 0-16-90-68-136-79-176-39-305-110-412-222-44-48-52-62-52-94 0-95 129-213 232-213 50 0 63-14 63-62 0-38 3-43 25-46 45-7 53-20 45-87-5-52-3-64 15-87 45-59 158-62 270-9 78 37 98 39 110 7s52-59 128-86c81-30 96-51 89-128-7-80-57-194-135-310-36-53-80-119-99-147-18-27-38-68-43-90-13-53-62-153-115-240-62-100-113-211-127-277-11-53-10-61 13-110 33-71 118-176 223-275 100-95 156-131 229-147 46-10 54-16 72-50 11-21 31-43 45-48 16-6 77-7 165-2 192 12 373 10 417-5 87-29 202-211 277-438 48-142 76-271 68-305-9-33-45-48-116-48-251 0-368-232-206-411 70-77 70-79 70-336v-232l35-36c32-33 35-41 34-93 0-69-30-133-128-274-163-236-272-553-283-823-9-227 23-310 177-459 144-138 191-146 304-50 22 19 51 34 64 34 14 0 49-18 78-41 64-49 125-69 214-69 172 0 367 85 591 256 53 41 117 83 143 95l47 20 42-34c58-47 188-131 252-162 68-34 89-28 111 33 38 105 43 112 64 112 12 0 56-18 98-40 123-63 122-63 195 13 70 73 131 107 244 137 101 27 165 59 180 90 16 33 41 50 75 50 142 0 415 328 449 540 16 100-3 239-66 485-73 281-109 534-120 835-20 533-86 703-426 1095-87 99-209 269-209 289 0 41-28 93-79 149-64 71-108 154-152 292-60 184-174 369-334 543-198 216-325 416-325 512 0 41 30 58 123 70 111 14 163 45 225 136 35 51 107 83 214 93 103 10 186 38 288 96 357 203 874 750 1086 1149 68 129 94 208 109 338 21 174 38 202 251 413 197 194 213 219 214 330 0 74-49 337-100 535-56 215-140 343-245 369-59 15-73 14-120-8z"/>
<path d="m1693 515c-174-45-367-156-408-236-8-15-15-52-15-82 0-66 23-101 87-128 65-28 249-59 385-66 225-11 289 31 309 204 10 86-3 219-26 262-38 74-161 90-332 46z"/>
</g>
</svg>`;
function main() {
const canvas = document.querySelector("#c");
const renderer = new THREE.WebGLRenderer({ antialias: true, canvas });
renderer.setClearColor(0xffffff);
const fov = 75;
const aspect = 1;
const near = 0.1;
const far = 13000;
const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
camera.position.z = 15000;
const scene = new THREE.Scene();
{
const color = 0xffffff;
const intensity = 1;
const light = new THREE.DirectionalLight(color, intensity);
light.position.set(-1, 2, 4);
scene.add(light);
}
var data = new THREE.SVGLoader().parse(svgString);
var paths = data.paths;
var shapes = [];
for (var i = 0; i < paths.length; i++) {
Array.prototype.push.apply(shapes, paths[i].toShapes()); // catenate, so we can create a single geometry and mesh
}
var extrusionSettings = {
depth: 200,
bevelEnabled: false
};
var geometry = new THREE.ExtrudeBufferGeometry(shapes, extrusionSettings);
geometry.center();
const material = new THREE.MeshPhongMaterial({ color: 0x4984c5 });
var mesh = new THREE.Mesh(geometry, material);
mesh.position.set(0, 0, 6000);
scene.add(mesh);
function render(time) {
time *= 0.0005; // convert time to seconds
mesh.rotation.y = time;
renderer.render(scene, camera);
requestAnimationFrame(render);
}
requestAnimationFrame(render);
}
main();
Also see: Tab Triggers