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.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Camp Activities Inquiry</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Shadows+Into+Light&display=swap" rel="stylesheet">
<style>
.camp-activities-inquiry light-regular {
font-family: "Shadows Into Light", cursive;
font-weight: 400;
font-style: normal;
}
body {
font-family: "Shadows Into Light", cursive;
font-weight: 400;
font-size: 30px;
font-style: normal;
display: flex;
justify-content: center;
height: 100vh;
margin: 0;
overflow: hidden;
transition: background-color 1s ease;
}
section {
padding: 20px;
border-radius: 10px;
display: flex;
margin-top: 100px;
flex-direction: column;
overflow: hidden;
width: 100%;
max-width: 500px;
height: auto;
font-family: "Shadows Into Light", cursive;
font-weight: 400;
font-size: 20px;
}
.card {
transition: height 0.5s ease-in-out;
display: flex;
flex-direction: column;
position: absolute;
margin-bottom: 20px; /* Adjust this value to control the gap between cards */
font-family: "Shadows Into Light", cursive;
font-weight: 400;
font-size: 20px;
}
.card label {
display: block;
margin-bottom: 5px;
font-size: 18px; /* Increase text size */
color: #333; /* Default text color */ /* Adjust this value to control the gap between label and input/select/textarea */
font-family: "Shadows Into Light", cursive;
font-weight: 400;
font-size: 25px;
}
/* Style for select element */
.card select {
width: 100%;
padding: 10px;
font-size: 16px;
margin-bottom: 10px;
border: none; /* Remove default border */
border-radius: 10px; /* Add border-radius for rounded edges */
appearance: none;
-webkit-appearance: none;
background-color: #f9f9f9; /* Background color for the select */
color: #333; /* Text color */
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* Add a box shadow */
transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease; /* Add transitions for smooth animation */
}
/* Style for option elements */
.card select option {
font-size: 16px;
border: none;
}
/* Style for when select is focused */
.card select:focus {
outline: none;
background-color: #fff; /* Change background color when focused */
color: #007bff; /* Change text color when focused */
box-shadow: 0 0 10px rgba(0, 123, 255, 0.5); /* Change box shadow when focused */
}
/* Style for open select */
.card.select-container.open::before {
background-color: rgba(255, 255, 255, 0); /* Semi-transparent white background */
backdrop-filter: blur(5px); /* Add blur effect */
z-index: 1; /* Ensure the blur layer is behind the select */
border-radius: 10px; /* Add border-radius to match the select */
}
/* Style for open select */
.card select.open {
animation: openSelect 0.3s ease; /* Add animation for opening */
}
/* Style for open select */
.card.select-container.open select {
border: none; /* Remove border when select is open */
outline: none; /* Remove outline when select is open */
}
@keyframes openSelect {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.card.select-container {
position: relative;
}
.card.select-container::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.8);
backdrop-filter: blur(5px);
z-index: 1;
border-radius: 10px;
}
.card button {
margin-right: 10px;
margin-bottom: 10px;
font-size: 16px;
color: #fff;
background-color: #007bff;
border: none;
border-radius: 4px;
padding: 8px 12px;
cursor: pointer;
width: 100px;
}
.hidden {
height: 0;
overflow: hidden;
visibility: hidden;
}
textarea {
width: 98%;
min-width: 98%;
min-height: 75px;
resize: vertical;
margin-bottom: 10px;
font-size: 16px;
color: #0099ff;
border: none;
border-bottom: 2px solid #007bff;
padding-bottom: 8px;
outline: none;
caret-color: blue;
background-color: transparent;
}
#activity-card label {
color: #1ff0ff;
}
#allergies-card label {
color: #993000;
}
#additional-info-card label {
color: #00c9fc;
}
#buttons_together {
display: flex;
justify-content: flex-start;
}
.card textarea::placeholder {
font-size: 20px;
color: #999;
}
.card button#back-btn, .card button#back-btn-2 {
background-color: transparent;
color: #ffffff;
border: 2px solid #727272;
border-radius: 5px;
padding: 8px 16px;
font-size: 16px;
cursor: pointer;
}
.card button#back-btn:hover, .card button#back-btn-2:hover {
background-color: #d3d3d3;
color:#000000
}
.card button#back-btn:active, .card button#back-btn-2:hover {
border-color: #999;
}
.background-image {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-size: cover;
background-position: center;
opacity: 0.75;
z-index: -1;
transition: opacity 0.5s ease;
}
.newclass {
font-family: "Shadows Into Light", cursive;
font-weight: 400;
font-size: 30px;
}
</style>
</head>
<body>
<section id="camp-activities-inquiry">
<div class="background-image"></div>
<h1 class="newclass">Camp Activities Inquiry</h1>
<form action="/submit-form" method="POST">
<div id="activity-card" class="card">
<label for="activity-select">Which camp activities are you most looking forward to?</label>
<select id="activity-select" name="activity">
<option value="">--Please choose an option--</option>
<option value="hiking">Hiking</option>
<option value="canoeing">Canoeing</option>
<option value="fishing">Fishing</option>
<option value="crafts">Crafts</option>
<option value="archery">Archery</option>
</select>
<button type="button" id="next-btn">Next</button>
</div>
<div id="allergies-card" class="card hidden">
<label for="food-allergies">Food Allergies (if any)</label>
<textarea id="food-allergies" name="food_allergies" rows="4" cols="50" placeholder="Write here..."></textarea>
<div id="buttons_together">
<button type="button" id="back-btn">Back</button>
<button type="button" id="next-btn-2">Next</button>
</div>
</div>
<div id="additional-info-card" class="card hidden">
<label for="additional-info">Additional things the counselor should know</label>
<textarea id="additional-info" name="additional_info" rows="4" cols="50" placeholder="Write here..."></textarea>
<div id="buttons_together">
<button type="button" id="back-btn-2">Back</button>
<button type="submit">Submit</button>
</div>
</div>
</form>
</section>
<script>
const activityCard = document.getElementById('activity-card');
const allergiesCard = document.getElementById('allergies-card');
const additionalInfoCard = document.getElementById('additional-info-card');
const nextBtn = document.getElementById('next-btn');
const nextBtn2 = document.getElementById('next-btn-2');
const backBtn = document.getElementById('back-btn');
const backBtn2 = document.getElementById('back-btn-2');
const background = document.querySelector('.background-image');
const hone = document.querySelector('.newclass');
const images = [
'https://images.unsplash.com/photo-1551632811-561732d1e306?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
'https://images.unsplash.com/photo-1458442310124-dde6edb43d10?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
'https://images.unsplash.com/photo-1444703686981-a3abbc4d4fe3?q=80&w=1470&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D'
];
background.style.backgroundImage = `url(${images[0]})`;
document.body.style.backgroundColor = 'lightgreen';
nextBtn.addEventListener('click', () => {
slideUp(activityCard);
slideDown(allergiesCard);
document.body.style.backgroundColor = 'lightblue';
background.style.backgroundImage = `url(${images[1]})`;
background.style.opacity = 0.75;
});
nextBtn2.addEventListener('click', () => {
slideUp(allergiesCard);
slideDown(additionalInfoCard);
document.body.style.backgroundColor = 'black';
background.style.backgroundImage = `url(${images[2]})`;
background.style.opacity = 0.75;
hone.style.color = 'white';
});
backBtn.addEventListener('click', () => {
slideUp(allergiesCard);
slideDown(activityCard);
document.body.style.backgroundColor = 'lightgreen';
background.style.backgroundImage = `url(${images[0]})`;
background.style.opacity = 0.75;
});
backBtn2.addEventListener('click', () => {
slideUp(additionalInfoCard);
slideDown(allergiesCard);
document.body.style.backgroundColor = 'lightblue';
background.style.backgroundImage = `url(${images[1]})`;
background.style.opacity = 0.75;
hone.style.color = 'black';
});
function slideUp(element) {
element.style.height = '0';
element.style.visibility = 'hidden';
}
function slideDown(element) {
element.style.visibility = 'visible';
const height = element.scrollHeight + 'px';
element.style.height = height;
}
document.addEventListener('DOMContentLoaded', function() {
const selects = document.querySelectorAll('.card select');
selects.forEach(select => {
select.addEventListener('click', function() {
this.classList.toggle('open');
});
});
});
</script>
</body>
</html>
Also see: Tab Triggers