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.
<!-- Learn about this code on sketchfab: https://sketchfab.com/developers/viewer -->
<center>
<!-- SketchFab Viewer -->
<div class="container">
<div class="iframe-container">
<iframe width="90%" height="400" src="" id="api-frame"></iframe>
</div>
<!-- Interactions -->
<div class="iframe-interactions">
<a href="" target="_blank" class="button ghost small ml-25 mobile-off w-button"> P L A Y </a>
</div>
<!-- Messengers -->
<p id="title" style="color: red"></p>
<p>Sound plays on load, if not, <a href="https://developers.google.com/web/updates/2018/11/web-audio-autoplay"> it means it needs a "user click/touch permission"</a></p>
</div>
<!-- Sourcing External Java Script for SketchFab Api -->
<script type="text/javascript" src="https://static.sketchfab.com/api/sketchfab-viewer-1.10.1.js"></script>
<script type="text/javascript" src="https://uploads-ssl.webflow.com/620eec9006a1e8735a6d67f7/624451d525b286e2d958f337_whitestormhead.txt"></script>
<!-- Audio -->
<audio controls autoplay id="audio1" loop=true preload width="960" height="540">
<source src="https://s3.us-west-2.amazonaws.com/secure.notion-static.com/373f8eff-a605-4883-ad38-4de6796be4d9/whitestorm.mp3?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAT73L2G45EIPT3X45%2F20220403%2Fus-west-2%2Fs3%2Faws4_request&X-Amz-Date=20220403T164737Z&X-Amz-Expires=86400&X-Amz-Signature=738b97273d9680eed1469a80c0a831358df7da595fe077eca2730d8e784ac30e&X-Amz-SignedHeaders=host&x-id=GetObject" id="srcMP3" type="audio/mp3">
<div>Your Browser will not support this audio</div>
</audio>
</center>
html,
body {
padding: 0;
margin: 0;
width: 100vw;
height: 100vh;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: grayscale;
font-family: Open Sans, sans-serif;
}
* {
box-sizing: border-box;
}
.container {
display: flex;
flex-direction: column;
height: 100%;
}
.iframe-container {
position: relative;
width: 100%;
flex: 1;
display: flex;
}
.iframe-container > iframe {
border: 0;
width: 100%;
flex: 1;
}
.controls {
display: flex;
align-items: center;
flex-wrap: wrap;
flex-shrink: 0;
min-height: 50px;
padding: 15px 0 0 15px;
background-color: #F2F2F2;
border-top: 1px solid #e7e7e7;
}
.controls > * {
margin-right: 15px;
margin-bottom: 15px;
}
button {
display: inline-flex;
justify-content: center;
align-items: center;
position: relative;
border: 2px solid transparent;
border-radius: 4px;
padding: 0 13px;
font-family: "Open Sans", sans-serif;
font-weight: 600;
text-align: center;
text-shadow: none;
text-transform: uppercase;
line-height: 1.2;
cursor: pointer;
outline: none;
transition: background 0.2s;
color: white;
background-color: #1caad9;
height: 25px;
font-size: 12px;
}
button.disabled {
background-color: #cccccc;
}
// Sketchfab Viewer API: Annotation hit also picks mesh
const version = '1.10.1';
const uid = '95d4b3b05ae946f7a4e89d224554a539';
const iframe = document.getElementById('api-frame');
const client = new window.Sketchfab(version, iframe);
let api;
const error = err => console.error('Sketchfab API error:', err);
var titleMessageElement;
var audioSample1;
var audioPlaying1;
function toggleAudio1() {
if (!audioSample1) return;
audioSample1.loop = true;
if (audioPlaying1) audioSample1.pause();
else audioSample1.play().then(function() {
window.console.log("// Automatic playback started!");
titleMessageElement.textContent = "// Automatic playback started!";
}).catch(function(error) {
// Automatic playback failed.
// Show a UI element to let the user manually start playback.
window.console.log("// Automatic playback couldn't start!");
window.console.log(error);
titleMessageElement.textContent = "// Automatic playback couldn't start! need user interaction";
});
}
function skfbStart() {
const success = apiClient => {
api = apiClient;
api.start();
api.addEventListener('viewerready', () => {
toggleAudio1();
});
};
client.init(uid, {
annotation: 0, // Usage: Setting to [1 – 100] will automatically load that annotation when the viewer starts.
annotations_visible: 1, // Usage: Setting to 0 will hide annotations by default.
autospin: 0, // Usage: Setting to any other number will cause the model to automatically spin around the z-axis after loading.
autostart: 1, // Usage: Setting to 1 will make the model load immediately once the page is ready, rather than waiting for a user to click the Play button.
cardboard: 0, // Usage: Start the viewer in stereoscopic VR Mode built for Google Cardboard and similar devices.
camera: 1, // Usage: Setting to 0 will skip the initial animation that occurs when a model is loaded, and immediately show the model in its default position.
preload: 1, // Usage: Setting to 1 will force all resources (textures) to download before the scene is displayed.
ui_stop: 0, // Usage: Setting to 0 will hide the "Disable Viewer" button in the top right so that users cannot stop the 3D render once it is started.
transparent: 0, // Usage: Setting to 1 will make the model's background transparent
ui_animations: 0, // Usage: Setting to 0 will hide the animation menu and timeline.
ui_annotations: 0, // Usage: Setting to 0 will hide the Annotation menu.
ui_controls: 1, // Usage: Setting to 0 will hide all the viewer controls at the bottom of the viewer (Help, Settings, Inspector, VR, Fullscreen, Annotations, and Animations).
ui_fullscreen: 1, // Usage: Setting to 0 will hide the Fullscreen button.
ui_general_controls: 1, // Usage: Setting to 0 will hide main control buttons in the bottom right of the viewer (Help, Settings, Inspector, VR, Fullscreen).
ui_help: 1, // Usage: Setting to 0 will hide the Help button.
ui_hint: 1, // Usage: Setting to 0 will always hide the viewer hint animation ("click & hold to rotate"). Setting to 1 will show the hint the first time per browser session (using a cookie). Setting to 2 will always show the hint.
ui_infos: 0, // Usage: Setting to 0 will hide the model info bar at the top of the viewer.
ui_inspector: 0, // Usage: Setting to 0 will hide the inspector button.
ui_settings: 0, // Usage: Setting to 0 will hide the Settings button.
ui_vr: 0, // Usage: Setting to 0 will hide the View in VR button.
ui_ar: 0, // Usage: Setting to 0 will hide the View in AR button.
ui_watermark_link: 0, // Usage: Setting to 0 remove the link from the Sketchfab logo watermark.
ui_color: '00a8c0', // Usage: Setting to a hexidecimal color code (without the #) or a HTML color name will change the color of the viewer loading bar.
ui_watermark: 0, // Usage: Setting to 0 remove the Sketchfab logo watermark.
success: success,
error: error,
version: version
});
}
document.addEventListener("DOMContentLoaded", function(event) {
// sound can be paused by user, browser, only way to know is to listen
// to the events
audioSample1 = document.getElementById('audio1');
audioSample1.addEventListener("playing", function(event) {
audioPlaying1 = true;
});
audioSample1.addEventListener("pause", function(event) {
audioPlaying1 = false;
});
titleMessageElement= document.getElementById('title');
skfbStart();
});
Also see: Tab Triggers