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 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.
<!-- Edit and Copy only the code in this 'HTML' code box and use by pasting it into your HTML code (ACC users must use an "HTML Block" in your ACC page). -->
<!-- Adjust Colors in lines 6-18 -->
<!-- Adjust Image (logo) and text in lines 180-184 -->
<style>
:root {
--behind-modal-grad-color-start: #ab6e80cc;
--behind-modal-grad-color-end: #9f6af5cc;
--behind-modal-grad-angle: 45deg;
--modal-border-size: .25em;
--modal-border-color: #003CFF;
--modal-border-radius: 20px;
--modal_background: #E9EFFF;
--close-x: #003CFF;
--logo-size: 40%;
--font-color: #005278;
--button-text: #003CFF;
--button-border: #003CFF;
--button-border-radius: 7px;
--button-background: #E9EFFF;
}
.img-replace {
/* replace 'close' text with an 'X' image */
display: inline-block;
overflow: hidden;
text-indent: 100%;
color: transparent;
white-space: nowrap;
}
.bts-popup {
position: fixed;
left: 0;
top: 0;
height: 100%;
width: 100%;
background-color: var(--behind-modal-color-start);
background: linear-gradient(var(--behind-modal-grad-angle), var(--behind-modal-grad-color-start), var(--behind-modal-grad-color-end));
opacity: 0;
visibility: hidden;
-webkit-transition: opacity 0.3s 0s, visibility 0s 0.3s;
-moz-transition: opacity 0.3s 0s, visibility 0s 0.3s;
transition: opacity 0.3s 0s, visibility 0s 0.3s;
}
.bts-popup.is-visible {
opacity: 1;
visibility: visible;
-webkit-transition: opacity 0.3s 0s, visibility 0s 0s;
-moz-transition: opacity 0.3s 0s, visibility 0s 0s;
transition: opacity 0.3s 0s, visibility 0s 0s;
}
.bts-popup-container {
position: relative;
width: 90%;
max-width: 500px;
margin: 4em auto;
background: var(--modal_background);
text-align: center;
box-shadow: 0 .25em 2em -2em black,
inset 0 0 0 var(--modal-border-size) var(--modal-border-color);
padding: 10px;
-webkit-transform: translateY(-40px);
-moz-transform: translateY(-40px);
-ms-transform: translateY(-40px);
-o-transform: translateY(-40px);
transform: translateY(-40px);
-webkit-backface-visibility: hidden;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
transition-property: transform;
-webkit-transition-duration: 0.3s;
-moz-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-border-radius: var(--modal-border-radius);
-moz-border-radius: var(--modal-border-radius);
border-radius: var(--modal-border-radius);
}
.bts-popup-container img {
padding: 20px 0 0 0;
width: var(--logo-size);
height: var(--logo-size);
}
.bts-popup-container p, .bts-popup-container h1, .bts-popup-container h2, .bts-popup-container h3 {
color: var(--font-color);
padding: 10px 40px;
}
.bts-popup-container .bts-popup-button {
padding: 5px 25px;
border: 2px solid var(--button-border);
background-color: var(--button-background);
display: inline-block;
margin-bottom: 10px;
-webkit-border-radius: var(--button-border-radius);
-moz-border-radius: var(--button-border-radius);
border-radius: var(--button-border-radius);
}
.bts-popup-container a {
color: var(--button-text);
text-decoration: none;
text-transform: uppercase;
}
.bts-popup-container .bts-popup-close {
position: absolute;
top: 18px;
right: 18px;
width: 30px;
height: 30px;
}
.bts-popup-container .bts-popup-close::before, .bts-popup-container .bts-popup-close::after {
content: '';
position: absolute;
top: 12px;
width: 16px;
height: 3px;
background-color: var(--close-x);
}
.bts-popup-container .bts-popup-close::before {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
left: 8px;
}
.bts-popup-container .bts-popup-close::after {
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
right: 6px;
top: 13px;
}
.is-visible .bts-popup-container {
-webkit-transform: translateY(0);
-moz-transform: translateY(0);
-ms-transform: translateY(0);
-o-transform: translateY(0);
transform: translateY(0);
}
iframe.rounded {
-webkit-border-radius: var(--modal-border-radius);
-moz-border-radius: var(--modal-border-radius);
border-radius: var(--modal-border-radius);
}
@media only screen and (min-width: 1170px) {
.bts-popup-container {
margin: 8em auto;
}
}
</style>
<script>
jQuery(document).ready(function($){
window.onload = function (){
$(".bts-popup").delay(1000).addClass('is-visible');
}
//open popup
$('.bts-popup-trigger').on('click', function(event){
event.preventDefault();
$('.bts-popup').addClass('is-visible');
});
//close popup
$('.bts-popup').on('click', function(event){
if( $(event.target).is('.bts-popup-close') || $(event.target).is('.bts-popup') ) {
event.preventDefault();
$(this).removeClass('is-visible');
}
});
//close popup when clicking the esc keyboard button
$(document).keyup(function(event){
if(event.which=='27'){
$('.bts-popup').removeClass('is-visible');
}
});
});
</script>
<div class="bts-popup" role="alert">
<div class="bts-popup-container">
<img data-cke-saved-src="https://i.imgur.com/IhuBwGZ.png" alt="" / src="https://i.imgur.com/IhuBwGZ.png" alt="" />
<h2>Easy Auto Popup Modal - V1</h2>
<p>This is a simple Drop-in automatic display Modal. Tested in the Organic, and Spruce Themes.</p>
<iframe class="rounded" width="400" height="225" src="https://www.youtube.com/embed/pn4XSDnaiPY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<br>
<br>
<div class="bts-popup-button">
<a data-cke-saved-href="/contact" href="/contact">Learn More</a>
</div>
<a data-cke-saved-href="#" class="bts-popup-close img-replace" href="#" class="bts-popup-close img-replace">Close</a>
</div>
</div>
/* The CSS is included in the HTML (lines 4-144) for easy Copy and Paste into an "HTML Block" */
// All of this Javascript is already included in the HTML (lines 145-172) for easy Copy and Paste into your HTML code (ACC users can add it as an "HTML Block" on your page). It is also here so that this Codpen also works //
jQuery(document).ready(function($){
window.onload = function (){
$(".bts-popup").delay(1000).addClass('is-visible');
}
//open popup
$('.bts-popup-trigger').on('click', function(event){
event.preventDefault();
$('.bts-popup').addClass('is-visible');
});
//close popup
$('.bts-popup').on('click', function(event){
if( $(event.target).is('.bts-popup-close') || $(event.target).is('.bts-popup') ) {
event.preventDefault();
$(this).removeClass('is-visible');
}
});
//close popup when clicking the esc keyboard button
$(document).keyup(function(event){
if(event.which=='27'){
$('.bts-popup').removeClass('is-visible');
}
});
});
Also see: Tab Triggers