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.
<!-- Due to the codepen sandboxing the form will not submit properly in this environment -->
<div class="background">
<div class="container">
<div class="row flex-column justify-content-center align-items-center text-center">
<div class="col-sm-12 col-md-10 col-lg-8">
<h1 id="time">12:00 AM</h1>
<h3 id="day" class="display-5">Monday, January 01</h3>
<h2 id="greeting">Good Morning, User.</h2>
<h3>What would you like to inquire about today?</h3>
</div><!-- /.col -->
</div><!-- /.row -->
<div class="row justify-content-center">
<div class="col-sm-12 col-md-10 col-lg-6">
<form action="https://www.google.com/search" method="get">
<div class="form-group">
<div class="input-group">
<input type="text" name="q" class="form-control custom-input">
<span class="input-group-btn">
<button class="btn btn-custom" type="submit"><i class="fa fa-search" aria-hidden="true"></i></button>
</span>
</div>
</div>
</form>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container -->
body {
font-family: 'Lato', sans-serif;
}
.background {
background: url('https://images.pexels.com/photos/91224/pexels-photo-91224.jpeg?w=940&h=650&auto=compress&cs=tinysrgb');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
min-height: 100vh; // For codepen purposes, height: 100vh works just fine.
color: white;
display: flex;
align-items: center;
justify-content: center;
position: relative;
&:before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0));
}
h1 {
font-size: 4rem;
font-weight: 700;
}
}
.custom-input, .btn-custom {
border: 0;
background: transparent;
border-bottom: 4px solid white;
border-radius: 0;
margin-bottom: 0;
}
.custom-input:focus {
border-color: white;
background: transparent;
color: white;
}
.btn-custom {
color: white;
cursor: pointer;
}
.display-5 {
font-size: 1.5rem;
}
#greeting {
margin-top: 2rem;
font-size: 2rem;
}
@media (min-width: 576px) {
.background h1 {
font-size: 5.5rem;
}
.display-5 {
font-size: 2.5rem;
}
#greeting {
margin-top: 2rem;
font-size: 2.5rem;
}
}
@media (min-width: 992px) {
.background h1 {
font-size: 6rem;
}
#greeting {
font-size: 3rem;
}
}
@media (min-width: 1200px) {
.background h1 {
font-size: 7.5rem;
}
#greeting {
font-size: 3.6rem;
}
}
// Document ready function
$(function() {
// Time function to get the date/time
function time() {
// Create new date var and init other vars
var date = new Date(),
hours = date.getHours(), // Get the hours
minutes = date.getMinutes().toString(), // Get minutes, convert to string
ante, // Will be used for AM and PM later
greeting, // Set the appropriate greeting for the time of day
dd = date.getDate().toString(), // Get the current day
userName = "User"; // Can be used to insert a unique name
/* Set the AM or PM according to the time, it is important to note that up
to this point in the code this is a 24 clock */
if (hours < 12) {
ante = "AM";
greeting = "Morning";
} else if (hours === 12 && hours >= 3) {
ante = "PM";
greeting = "Afternoon"
} else {
ante = "PM";
greeting = "Evening";
}
/* Since it is a 24 hour clock, 0 represents 12am, if that is the case
then convert that to 12 */
if (hours === 0) {
hours = 12;
/* For any other case where hours is not equal to twelve, let's use modulus
to get the corresponding time equivilant */
} else if (hours !== 12) {
hours = hours % 12;
}
// Minutes can be in single digits, hence let's add a 0 when the length is less than two
if (minutes.length < 2) {
minutes = "0" + minutes;
}
// Let's do the same thing above here for the day
if (dd.length < 2) {
dd = "0" + dd;
}
// Months
Date.prototype.monthNames = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
// Days
Date.prototype.weekNames = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
];
// Return the month name according to its number value
Date.prototype.getMonthName = function() {
return this.monthNames[this.getMonth()];
};
// Return the day's name according to its number value
Date.prototype.getWeekName = function() {
return this.weekNames[this.getDay()];
};
// Display the following in html
$("#time").html(hours + ":" + minutes + " " + ante);
$("#day").html(date.getWeekName() + ", " + date.getMonthName() + " " + dd);
$("#greeting").html("Good " + greeting + ", " + userName + ".");
// The interval is necessary for proper time syncing
setInterval(time, 1000);
}
time();
});
Also see: Tab Triggers