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="overlay"></div>
<div class="popup">
<button class="popup__close">✕</button>
<!-- Question 1-->
<div class="popup__content question-visible">
<h2 class="popup__title">What series should I watch?</h2>
<p class="popup__subtitle">Take this four-question quiz and discover your movie match!</p>
<div class="popup__progress">
<div class="popup__progress-item popup__progress-item_active">1</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item ">2</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item">3</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item">4</div>
</div>
<div class="quiz">
<h5 class="quiz__question">What genre do you prefer?</h5>
<div class="quiz__answers">
<label class="container">Comedy
<input type="radio" name="option1" class="quiz__input">
<span class="checkmark"></span>
</label>
<label class="container">Drama
<input type="radio" name="option1" class="quiz__input">
<span class="checkmark"></span>
</label>
<label class="container"> Sci-fi
<input type="radio" name="option1" class="quiz__input">
<span class="checkmark"></span>
</label>
<label class="container"> Horror
<input type="radio" name="option1" class="quiz__input">
<span class="checkmark"></span>
</label>
</div>
<button class="popup__button" id="popupButton1" disabled="true">Next</button>
</div>
</div>
<!-- Question 2-->
<div class="popup__content">
<h2 class="popup__title">What TV show should I watch?</h2>
<p class="popup__subtitle">Take this four-question quiz and discover your movie match!</p>
<div class="popup__progress">
<div class="popup__progress-item">
🗸
</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item popup__progress-item_active">2</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item">3</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item">4</div>
</div>
<div class="quiz">
<h5 class="quiz__question">What kind of setting do you like?</h5>
<div class="quiz__answers">
<label class="container">Futuristic
<input type="radio" name="option2" class="quiz__input">
<span class="checkmark"></span>
</label>
<label class="container">Historical
<input type="radio" name="option2" class="quiz__input">
<span class="checkmark"></span>
</label>
<label class="container">Alternate reality
<input type="radio" name="option2" class="quiz__input">
<span class="checkmark"></span>
</label>
<label class="container">Space
<input type="radio" name="option2" class="quiz__input">
<span class="checkmark"></span>
</label>
</div>
<button class="popup__button" id="popupButton2" disabled="true">Next</button>
</div>
</div>
<!-- Question 3-->
<div class="popup__content">
<h2 class="popup__title">What TV show should I watch?</h2>
<p class="popup__subtitle">Take this four-question quiz and discover your movie match!</p>
<div class="popup__progress">
<div class="popup__progress-item">
🗸
</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item">
🗸
</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item popup__progress-item_active">3</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item">4</div>
</div>
<div class="quiz">
<h5 class="quiz__question">What kind of characters do you like?</h5>
<div class="quiz__answers">
<label class="container">Superheroes
<input type="radio" name="option3" class="quiz__input">
<span class="checkmark"></span>
</label>
<label class="container">Time travelers
<input type="radio" name="option3" class="quiz__input">
<span class="checkmark"></span>
</label>
<label class="container">Mutants
<input type="radio" name="option3" class="quiz__input">
<span class="checkmark"></span>
</label>
</div>
<button class="popup__button" id="popupButton3" disabled="true">Next</button>
</div>
</div>
<!-- Question 4-->
<div class="popup__content">
<h2 class="popup__title">What TV show should I watch?</h2>
<p class="popup__subtitle">Take this four-question quiz and discover your movie match!</p>
<div class="popup__progress">
<div class="popup__progress-item">
🗸
</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item">
🗸
</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item">
🗸
</div>
<div class="popup__progress-line"></div>
<div class="popup__progress-item popup__progress-item_active">4</div>
</div>
<div class="quiz">
<h5 class="quiz__question">Choose one series that you liked</h5>
<div class="quiz__answers quiz__answers_images">
<label class="container container_images">
<img src="https://th.bing.com/th/id/OIP.pNlTFkxtPD8XTKw13qqNJQHaK-?pid=ImgDet&rs=1" alt="movie">
<input type="radio" name="option4" class="quiz__input">
<span class="checkmark checkmark_images"></span>
</label>
<label class="container container_images">
<img src="https://th.bing.com/th/id/OIP.j9gSPKdfACS7RjMu9H08ugHaLH?pid=ImgDet&rs=1" alt="movie">
<input type="radio" name="option5" class="quiz__input">
<span class="checkmark checkmark_images"></span>
</label>
<label class="container container_images">
<img src="https://th.bing.com/th/id/R.e08a111d661dd83e55e0ad19c1de0f1b?rik=T8lYPSwtrGzvfg&riu=http%3a%2f%2fcdn.collider.com%2fwp-content%2fuploads%2fthe-office-season-seven-dvd-cover.jpg&ehk=Rd0gLUa6fGjp5IWbL7TZaHT29DbwWecdqTi7KnmY5yY%3d&risl=&pid=ImgRaw&r=0" alt="movie">
<input type="radio" name="option4" class="quiz__input">
<span class="checkmark checkmark_images"></span>
</label>
</div>
<button class="popup__button" id="popupButton4" disabled="true">Next</button>
</div>
</div>
<!-- Final Slide -->
<div class="popup__content popup__content6">
<h2 class="popup__title">Great! Here is the perfect series for you: ....</h2>
<img src="https://images.unsplash.com/photo-1635616208778-3d034a225ac6?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=764&q=80" alt="movies" class="popup__final-img">
</div>
</div>
body {
background-image: url("https://images.unsplash.com/photo-1505775561242-727b7fba20f0?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1170&q=80");
background-repeat: no-repeat;
background-size: cover;
}
.overlay {
opacity: 0;
position: fixed;
z-index: 10;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.7);
filter: blur(6px);
transition: 120ms ease;
overflow: hidden;
}
.overlay_visible {
opacity: 1;
}
.popup {
box-sizing: border-box;
z-index: 25;
box-shadow: 0 2px 5px 5px rgba(0, 0, 0, 0.1);
position: fixed;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #fff;
border-radius: 24px;
width: 700px;
height: 92vh;
max-height: 420px;
min-height: 380px;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0;
visibility: hidden;
padding: 0 50px;
}
.popup__final-img {
max-width: 220px;
height: auto;
margin-top: 20px;
align-self: center;
border-radius: 5px;
}
.popup__content {
display: none;
margin: 0 auto;
flex-direction: column;
transition: all 3s ease;
transform: translateX(-15px);
}
.question-visible {
transition: all 3s ease;
display: flex;
transform: translateX(0);
}
.popup__progress-item img {
width: 14px;
height: 10px;
}
.popup_visible {
transform: translate(-50%, -50%);
opacity: 1;
visibility: visible;
transition: 0.5s;
top: 50%;
}
.popup__title {
text-align: center;
font-size: 22px;
font-weight: 700;
padding: 0;
margin: 10px 0 0;
}
.popup__subtitle {
text-align: center;
font-size: 18px;
font-weight: 500;
margin: 8px 0;
padding: 0;
}
.popup__close {
color: #525252;
z-index: 21;
position: absolute;
top: 0;
right: 22px;
height: 16px;
width: 16px;
background-color: transparent;
border: none;
outline-color: transparent;
padding: 6px 12px 12px;
font-weight: 800;
font-size: 22px;
cursor: pointer;
}
.popup__button {
margin: 8px auto 0;
padding: 8px 0;
border-radius: 8px;
font-size: 18px;
font-weight: 600;
outline-color: transparent;
border: none;
background-color: #f25042;
color: #fff;
width: 176px;
height: 40px;
cursor: pointer;
}
.popup__button:disabled {
margin: 8px auto 0;
padding: 8px 0;
border-radius: 8px;
font-size: 18px;
font-weight: 600;
outline-color: transparent;
border: none;
background-color: #dfdfdf;
color: #fff;
width: 176px;
height: 40px;
}
.popup__progress {
margin-top: 10px;
display: flex;
align-items: center;
align-self: center;
}
.popup__progress-line {
height: 2px;
width: 48px;
background-color: #f25042;
}
.popup__progress-item {
height: 38px;
width: 38px;
border-radius: 50%;
border: 2px solid #f25042;
color: #d20f26;
font-size: 16px;
font-weight: 600;
display: flex;
justify-content: center;
align-items: center;
}
.popup__progress-item_active {
background-color: #f25042;
color: #fff;
}
.quiz {
display: flex;
flex-direction: column;
}
.quiz__question {
font-size: 18px;
font-weight: 600;
margin: 0;
padding: 16px 0 12px;
}
.quiz__answers_images {
display: flex;
}
/* Customize the label (the container) */
.container {
display: block;
position: relative;
padding-left: 30px;
margin-bottom: 16px;
cursor: pointer;
font-size: 16px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.container_images {
padding: 0;
margin: 0 auto 40px;
}
.container_images > img {
width: 110px;
height: 130px;
object-fit: cover;
}
.container_images:not(:first-of-type) {
padding-left: 23px;
}
/* Hide the browser's default radio button */
.container input {
position: absolute;
opacity: 0;
cursor: pointer;
height: 0;
width: 0;
}
/* Create a custom radio button */
.checkmark {
position: absolute;
top: 0;
left: 0;
height: 12px;
width: 12px;
background-color: #fff;
border-radius: 50%;
border: 2.5px solid #808080;
}
.checkmark_images {
bottom: -26px;
left: 50%;
top: auto;
}
/* Create the indicator (the dot/circle - hidden when not checked) */
.checkmark:after {
content: "";
position: absolute;
display: none;
}
/* Show the indicator (dot/circle) when checked */
.container input:checked ~ .checkmark:after {
display: block;
}
.container input:checked ~ .checkmark {
border: 2px solid #f25042;
}
/* Style the indicator (dot/circle) */
.container .checkmark:after {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 8.5px;
height: 8.5px;
border-radius: 50%;
background: #f25042;
}
const overlay = document.querySelector(".overlay");
const popup = document.querySelector(".popup");
const cross = popup.querySelector(".popup__close");
function openPopup() {
overlay.addEventListener("click", closePopup);
cross.addEventListener("click", closePopup);
overlay.classList.add("overlay_visible");
popup.classList.add("popup_visible");
}
openPopup();
function closePopup() {
overlay.classList.remove("overlay_visible");
popup.classList.remove("popup_visible");
document.body.classList.remove("body_blur");
overlay.removeEventListener("click", closePopup);
cross.removeEventListener("click", closePopup);
}
// Опросник
const quizes = document.querySelectorAll(".quiz");
const questions = document.querySelectorAll(".popup__content");
quizes.forEach((quiz) => {
const options = quiz.querySelectorAll(".quiz__input");
const nextButton = quiz.querySelector(".popup__button");
options.forEach((option) => {
option.addEventListener("click", () => {
nextButton.disabled = false;
});
});
});
questions.forEach((question, i) => {
const button = document.getElementById(`popupButton${i + 1}`);
button.addEventListener("click", () => {
question.classList.remove("question-visible");
if (questions[i + 1]) {
questions[i + 1].classList.add("question-visible");
}
});
});
Also see: Tab Triggers