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.
<div class="container">
<section id="ico" class="ico active animate">
<div class="btn enter" id="contact">
<div><span><svg style="width:24px;height:24px" viewBox="0 0 24 24">
<path fill="#000000" d="M22 6C22 4.9 21.1 4 20 4H4C2.9 4 2 4.9 2 6V18C2 19.1 2.9 20 4 20H20C21.1 20 22 19.1 22 18V6M20 6L12 11L4 6H20M20 18H4V8L12 13L20 8V18Z" />
</svg></span><span class="text"><span>CONTACT</span></span>
</div>
</div>
</section>
<section id="frm">
<div class="form-wrapper">
<h3 class="text-center"><span>CONTACT</span></h3>
<p>This contact form is for design only. To contact me, visit my <a href="https://rachelhcreative.com" target="web">website</a>. Please try this form out to see what it does. </p>
<div class="form-group">
<label for="name">Name <span class="red">*</span></label>
<input type="text" class="form-control" required id="name" placeholder="Your name">
</div>
<div class="form-group">
<label for="email">Email address <span class="red">*</span></label>
<input type="email" class="form-control" required id="email" aria-describedby="emailHelp" placeholder="you@email.com">
<small id="emailHelp" class="form-text">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="details">Details</label>
<textarea class="form-control" id="details" rows="3"></textarea>
</div>
<div id="frm-sb" class="button">SUBMIT</div>
</div>
</section>
<section id="thx">
<div class="thx-wrapper">
<h3 class="text-center"><span>THANK YOU</span></h3>
<p><span id="user"></span>, thank you for testing out my form. If you want to contact me or view more of my projects visit my website:
<div class="text-center"><a href="https://rachelhdesigner.com" target="_blank">Rachel H. Designer</a></div>
</p>
<div class="output">
<p>Name: <span id="fullname"></span></p>
<p>Email: <span id="eml"></span></p>
<p id="det"></p>
</div>
<div>
<div id="frm-st" class="btn custom">
<div><span><svg style="width:24px;height:24px" viewBox="0 0 24 24">
<path fill="#000000" d="M12.5,8C9.85,8 7.45,9 5.6,10.6L2,7V16H11L7.38,12.38C8.77,11.22 10.54,10.5 12.5,10.5C16.04,10.5 19.05,12.81 20.1,16L22.47,15.22C21.08,11.03 17.15,8 12.5,8Z" />
</svg></span><span class="text"><span>Start Over</span></span>
</div>
</div>
</div>
</div>
</section>
</div>
/*/dark blue : #00546f*/
body {
min-height: 200vh;
width: 100vw;
background-color: #e9e9e9;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' viewBox='0 0 16 32'%3E%3Cg fill='%2300546f' fill-opacity='0.09'%3E%3Cpath fill-rule='evenodd' d='M0 24h4v2H0v-2zm0 4h6v2H0v-2zm0-8h2v2H0v-2zM0 0h4v2H0V0zm0 4h2v2H0V4zm16 20h-6v2h6v-2zm0 4H8v2h8v-2zm0-8h-4v2h4v-2zm0-20h-6v2h6V0zm0 4h-4v2h4V4zm-2 12h2v2h-2v-2zm0-8h2v2h-2V8zM2 8h10v2H2V8zm0 8h10v2H2v-2zm-2-4h14v2H0v-2zm4-8h6v2H4V4zm0 16h6v2H4v-2zM6 0h2v2H6V0zm0 24h2v2H6v-2z'/%3E%3C/g%3E%3C/svg%3E");
font-family: "Asap", sans-serif;
}
.container {
}
section {
display: none;
}
section.active {
display: block;
height: 100vh;
}
.btn.enter {
position: absolute;
top: 50%;
left: 50%;
transform: scale(2);
}
.btn {
position: absolute;
top: 50%;
left: 50%;
background-color: #00546f;
transition: b40ackground-color 250ms ease-in-out;
color: white;
border-radius: 10px;
font-size: small;
font-weight: bold;
}
.btn.custom {
position: absolute;
left: 40px;
top: 400px;
background-color: rgba(255, 255, 255, 0.2);
}
.btn span:nth-child(2) {
max-width: 0;
-webkit-transition: max-width 650ms;
transition: max-width 650ms;
display: inline-block;
vertical-align: top;
white-space: nowrap;
overflow: hidden;
}
.btn:hover {
background-color: #008db9;
}
.btn:hover span {
max-width: 8rem;
}
.btn span:nth-child(2) > span {
padding-right: 20px;
position: relative;
top: 2px;
left: 10px;
min-width: 100px;
}
.text {
text-transform: uppercase;
font-weight: bold;
}
.btn > div > span > svg > path {
fill: white;
}
footer {
padding-bottom: 20px;
}
.ftr-lnk {
color: #008db9;
text-decoration: none;
}
.red {
color: crimson;
font-weight: bold;
}
#frm,
#thx {
padding: 30px 40px;
margin: 30px 0px;
background-color: #00546f;
color: #fff;
min-height: 700px;
border: 10px solid #e9e9e9;
}
#thx {
min-height: 700px;
}
.container {
display: flex;
flex-direction: column;
}
#frm a:link,
#frm a:visited {
color: white;
text-decoration: underline;
}
small {
color: #ffffff;
}
h3 {
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
padding-bottom: 10px;
padding-top: 10px;
margin-bottom: 20px;
}
.button {
cursor: pointer;
background-color: #008db9;
border-radius: 10px;
padding: 10px;
text-align: center;
color: #fff;
margin-top: 40px;
font-weight: bold;
transition: background-color 250ms ease, color 250ms ease;
}
.button:hover {
background-color: #b2cbd3;
color: #444;
}
.required {
background-color: #fef79b;
border: 1px solid red;
}
#thx a:link,
#thx a:visited {
font-size: larger;
color: #fff;
text-decoration: underline;
}
.custom > span > svg > path {
fill: white;
}
.custom > span:nth-child(2) {
padding-left: 10px;
}
.custom {
}
section {
opacity: 0;
}
.animate {
-webkit-animation: fade-in-fwd 0.6s cubic-bezier(0.39, 0.575, 0.565, 1) 1s
forwards;
animation: fade-in-fwd 0.6s cubic-bezier(0.39, 0.575, 0.565, 1) 1s forwards;
}
/* ----------------------------------------------
* Generated by Animista on 2019-12-23 7:44:58
* Licensed under FreeBSD License.
* See http://animista.net/license for more info.
* w: http://animista.net, t: @cssanimista
* ---------------------------------------------- */
/**
* ----------------------------------------
* animation fade-in-fwd
* ----------------------------------------
*/
@-webkit-keyframes fade-in-fwd {
0% {
-webkit-transform: translateZ(-80px);
transform: translateZ(-80px);
opacity: 0;
}
100% {
-webkit-transform: translateZ(0);
transform: translateZ(0);
opacity: 1;
}
}
@keyframes fade-in-fwd {
0% {
-webkit-transform: translateZ(-80px);
transform: translateZ(-80px);
opacity: 0;
}
100% {
-webkit-transform: translateZ(0);
transform: translateZ(0);
opacity: 1;
}
}
//to create a ui contact button with animation
//to create on click event that will display a simple
//contact form that will only "submit" when the user fills in the
//correct fields
// to display a thank you message using the data that user put in
// the form and to have a reset this page "button event"
(function() {
"use strict";
var tst = 0;
var ct = document.getElementById("contact");
var ico = document.getElementById("ico");
var frm = document.getElementById("frm");
var thx = document.getElementById("thx");
var det = document.getElementById("details");
var frmbtn = document.getElementById("frm-sb");
var user = document.getElementById("user");
var fnm = document.getElementById("fullname");
var eml = document.getElementById("eml");
var details = document.getElementById("details");
var det = document.getElementById("det");
function valid(id) {
if (id.value === "") {
id.classList.add("required");
} else {
id.classList.remove("required");
tst++;
}
}
ct.addEventListener("click", function() {
ico.classList.remove("active");
frm.classList.add("active");
frm.classList.add("animate");
});
var name = document.getElementById("name");
var email = document.getElementById("email");
frmbtn.addEventListener("click", function() {
valid(name);
valid(email);
if (tst === 2) {
frm.classList.remove("active");
document.body.scrollTop = document.documentElement.scrollTop = 0;
thx.classList.add("active");
thx.classList.add("animate");
user.innerHTML = name.value;
eml.innerHTML = email.value;
fnm.innerHTML = name.value;
if (details.value !== "") {
det.innerHTML = "<span>Details: </span>" + details.value;
} else {
det.innerHTML = "<span>No further details given.</span>";
}
}
});
document.getElementById("frm-st").addEventListener("click", function() {
thx.classList.remove("active");
document.body.scrollTop = document.documentElement.scrollTop = 0;
ico.classList.add("active");
ico.classList.add("animate");
email.value("");
name.value("");
details.value("");
});
})();
Also see: Tab Triggers