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.
Private Pens are hidden everywhere on CodePen, except to you. You can still share them and other people can see them, they just can't find them through searching or browsing.
Upgrade to PROIf 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.
Templates are Pens that can be used to start other Pens quickly from the create menu. The new Pen will copy all the code and settings from the template and make a new Pen (that is not a fork). You can view all of your templates, or learn more in the documentation.
Any Pen can act as a template (even if you don't flip the toggle above) with a special URL you can use yourself or share with others. Here's this Pen's template URL:
Screenshots of Pens are shown in mobile browsers, RSS feeds, to users who chose images instead of iframes, and in social media sharing.
This Pen is using the default Screenshot, generated by CodePen. Upgrade to PRO to upload your own thumbnail that will be displayed on previews of this pen throughout the site and when sharing to social media.
Upgrade to PRO
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sauvignon Blanc</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="new.css">
<link href="https://fonts.googleapis.com/css?family=Cormorant+Garamond|La+Belle+Aurore|Roboto+Condensed:400,700|Roboto+Slab:100,300" rel="stylesheet">
</head>
<body>
<header>
<div id="wineheader"></div>
<img src="img/sb_logo.svg" alt="" id="logo">
<nav>
<ul>
<li><a href="index.html">home</a></li>
<li><a href="wine.html">wines</a></li>
<li><a href="about.html">about</a></li>
</ul>
</nav>
<div id="winetitle">Sauvignon Blanc</div>
<div id="winesubtitle">Delve into the world of</div>
</header>
<main id="winegrid">
</main>
<footer>
<p class="footer_1p">Drink Responsobly.</p>
<p class="footer_2p">Terms of use | Privacy policy </p>
</footer>
<template id="myTemp">
<article>
<button class="wineWrapper" id="myBtn">
<img class="wineImage" src="" alt="">
<p class="name">HERE GOES THE WINE NAME</p>
<p class="wineHouse">HERE GOES THE WINE HOUSE NAME</p>
<p class="area">HERE GOES THE WINE MAKING AREA</p>
<p class="rating">HERE GOES THE RATING NUMBER</p>
<img class="ratingImage" src="" alt="">
</button>
<div class="modal" id="myModal">
<div class="modal-content">
<p class="wineDescription">WINE DESCRIPTION</p>
<span class="close">×</span>
</div>
</div>
</article>
</template>
</body>
</html>
* {
margin: 0;
padding: 0;
}
body {
min-width: 100vw;
width: auto !important;
margin: 0 auto;
/* max-width: 1140px;*/
background-color: #FCFCFC;
}
/* HEADER BEGINS */
#indexheader {
background-image: url(img/landscape-vineyard-edited.jpg);
background-size: cover;
height: 100vh;
height: calc(var(--vh, 1vh) *100);
width: 100%;
}
#logo {
padding: 1rem;
position: absolute;
top: 0;
width: 40px;
}
nav {
display: inline-block;
position: absolute;
margin: 2rem -1rem;
top: 0;
left: 6rem;
}
nav ul {
display: inline-block;
}
nav li {
font-family: "La Belle Aurore", serif;
color: white;
list-style-type: none;
display: inline-block;
padding-right: 3rem;
font-size: 1.6rem;
}
a {
color: inherit;
text-decoration: inherit;
}
/* HEADER ENDS*/
/* INDEX PAGE BEGINS */
#indexTitle {
font-family: "La Belle Aurore", serif;
font-size: 3rem;
color: white;
position: absolute;
top: 22rem;
left: 1rem;
}
#indexSubtitle {
font-family: "Roboto Condensed", serif;
font-size: 1rem;
color: white;
position: absolute;
top: 26rem;
left: 12.5rem;
}
.indexMain {
/* THIS IS THE GRID FOR THE INDEX PAGE */
display: grid;
grid-template-columns: 1fr;
}
.article-box {
display: block;
text-align: center;
padding: 10px;
min-height: 250px;
}
.article-box h1 {
font-family: "La Belle Aurore", serif;
font-size: 1.8rem;
margin-top: 10px;
color: #313029;
}
.article-box .index-article {
font-family: "Cormorant Garamond", sans-serif;
padding: 5% 0;
font-size: 1rem;
line-height: 1.4rem;
color: #313029;
}
hr {
/* CREATES THE UNDERLINE FOR THE HEADERS */
display: block;
height: 1px;
border: 0;
border-top: 1px solid #567947;
margin: 0 auto;
width: 20%;
}
.placeholder {
/* IMAGES ON THE INDEX PAGE */
max-width: 100%;
object-fit: contain;
text-align: center;
}
.five {
background-color: #F5F7F2;
height: 100%;
text-align: center;
}
.five .quote {
font-family: "La Belle Aurore", serif;
font-size: 1.6rem;
padding: 10% 20px;
color: #313029;
}
/* INDEX PAGE ENDS HERE */
/* WINE PAGE BEGINS HERE*/
#wineheader {
height: 30vh;
height: calc(var(--vh, 1vh) *30);
background-image: url(img/house-bg.png);
background-repeat: no-repeat;
background-size: cover;
background-position: center center;
}
#winetitle {
font-family: "La Belle Aurore", serif;
font-size: 2.2rem;
color: white;
position: absolute;
top: 8rem;
left: 5rem;
}
#winesubtitle {
font-family: "Roboto Condensed", serif;
font-size: .8rem;
color: white;
position: absolute;
top: 7.7rem;
left: 3.5rem;
}
#winegrid {
display: grid;
grid-template-columns: 1fr;
grid-row-gap: 40px;
width: 70%;
margin: 20px auto;
}
article {
width: 100%;
}
article .wineImage {
width: 50%;
margin: 0 auto;
display: block;
}
article .name {
font-family: 'Roboto Condensed', sans-serif;
font-size: 1.1rem;
font-weight: 400;
margin-top: 5px;
}
article .wineHouse {
font-family: 'Roboto Slab', serif;
font-size: .9em;
font-weight: 100;
margin-top: 4px;
}
article .area {
font-family: 'Roboto Slab', serif;
font-size: .9rem;
font-weight: 100;
}
article .rating {
font-family: 'Roboto Condensed', sans-serif;
font-size: 2rem;
margin: 10px 0 5px 0;
}
article .ratingImage {
width: 30%;
}
/*MODAL BEGINS HERE*/
/*background modal*/
.modal {
display: none;/* hidden to start */
/* position: fixed; stay in place */
z-index: 1; /* on top of z-ax */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content/Box */
.modal-content {
background-color: #fefefe;
margin: 15% auto; /* 15% from the top and centered */
padding: 20px;
border: 1px solid #888;
width: 80%; /* Could be more or less, depending on screen size */
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
/*MODAL ENDS HERE */
/* WINE PAGE ENDS HERE*/
/* ABOUT PAGE STARTS HERE */
#aboutheader {
background-image: url(img/house-bg.png);
background-size: cover;
height: 100vh;
height: calc(var(--vh, 1vh) *100);
width: 100%;
}
.about-me-box {
display: block;
position: absolute;
width: 80%;
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
top: 13rem;
left: 2.3rem
}
.about-me-box h1 {
font-family: "La Belle Aurore", serif;
font-size: 1.8rem;
color: #313029;
}
.about-me-box p {
font-family: "Cormorant Garamond", sans-serif;
padding: 5% 5%;
font-size: 1rem;
line-height: 1.4rem;
color: #313029;
}
/* ABOUT PAGE ENDS HERE */
/* FOOTER BEGINS HERE*/
footer {
height: 8vh;
text-align: center;
padding: 15px 20px;
}
.footer_1p {
font-family: "Cormorant Garamond", sans-serif;
font-size: 1rem;
color: #313029;
}
.footer_2p {
font-family: "Cormorant Garamond", sans-serif;
font-size: .9rem;
color: #313029;
margin-top: 10px;
}
/* FOOTER ENDS HERE*/
/* TABLET VIEW */
@media only screen and (min-width: 600px) {
/* TABLET INDEX STARTS HERE */
#indexTitle {
font-size: 4rem;
position: absolute;
top: 33rem;
left: 3rem;
}
#indexSubtitle {
font-size: 1.1rem;
position: absolute;
top: 38.5rem;
left: 24rem;
}
.article-box .index-article {
padding: 3% 10%;
font-size: 1.1rem;
line-height: 1.6rem;
}
.five .quote {
font-size: 2rem;
padding: 10% 20px;
color: #313029;
}
/* TABLET INDEX ENDS HERE */
/* TABLET WINE PAGE BEGINS HERE*/
#winetitle {
font-size: 2.7rem;
position: absolute;
top: 7.3rem;
left: 10.5rem;
}
#winesubtitle {
font-size: .9rem;
position: absolute;
top: 7rem;
left: 8rem;
}
#winegrid {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 3rem;
grid-row-gap: 0;
grid-auto-rows: minmax(100px, auto);
width: 90%;
margin: 0 auto;
}
article {
width: 100%;
padding: 20px;
}
article .wineImage {
width: 50%;
margin: 0 auto;
display: block;
}
article .name {
font-size: 1.2rem;
margin-top: 5px;
}
article .wineHouse {
font-size: .9em;
margin-top: 4px;
}
article .area {
font-size: .9rem;
}
article .rating {
font-size: 2rem;
margin: 10px 0 5px 0;
}
article .ratingImage {
width: 40%;
}
/* TABLET WINE PAGE ENDS HERE*/
/* TABLET ABOUT PAGE STARTS HERE */
.about-me-box {
width: 70%;
top: 13rem;
left: 7rem
}
.about-me-box h1 {
font-size: 2.3rem;
}
.about-me-box p {
padding: 3% 5% 5% 5%;
font-size: 1.2rem;
line-height: 1.5rem;
}
/* TABLET ABOUT PAGE ENDS HERE */
/* TABLET FOOTER STARTS HERE */
footer {
height: 5vh;
text-align: right;
padding: 20px 25px;
}
.footer_1p {
font-size: 1.1rem;
}
.footer_2p {
font-size: 1rem;
margin-top: 5px;
}
/* TABLET FOOTER ENDS HERE */
}
/* DESKTOP VIEW */
@media only screen and (min-width: 1300px) {
#logo {
padding: 1rem 2rem;
position: absolute;
width: 40px;
}
/* DESKTOP INDEX STARTS HERE */
.indexMain {
/* THIS IS THE GRID FOR THE INDEX PAGE */
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-auto-rows: minmax(100px, auto);
}
#indexTitle {
font-size: 6rem;
position: absolute;
top: 35rem;
left: 9rem;
}
#indexSubtitle {
font-size: 1.6rem;
position: absolute;
top: 43rem;
left: 38rem;
}
.article-box {
text-align: left;
}
.article-box h1 {
font-family: "La Belle Aurore", serif;
font-size: 2.6rem;
margin: 0;
}
.article-box .index-article {
font-size: 1.4rem;
line-height: 2rem;
padding: 5% 2rem 5% 0;
}
hr {
/* CREATES THE UNDERLINE FOR THE HEADERS */
margin: 0;
}
.one {
grid-column: 1;
grid-row: 1;
align-self: center;
padding-left: 5%;
}
.two {
grid-column: 2;
grid-row: 1;
}
.three {
grid-column: 1;
grid-row: 2;
}
.four {
grid-column: 2;
grid-row: 2;
align-self: center;
padding-left: 5%;
}
.five {
grid-column: 1 / 3;
grid-row: 3;
text-align: center;
background-color: #F5F7F2;
}
.five .quote {
font-size: 3rem;
}
.six {
grid-column: 1;
grid-row: 4;
align-self: center;
padding-left: 5%;
}
.seven {
grid-column: 2;
grid-row: 4;
}
.placeholder {
/* IMAGES ON THE INDEX PAGE */
max-width: 100%;
object-fit: contain;
}
/* DESKTOP INDEX ENDS HERE */
/* DESKTOP WINE PAGE BEGINS HERE*/
#winetitle {
font-size: 4rem;
position: absolute;
top: 8.5rem;
left: 38rem;
}
#winesubtitle {
font-size: 1em;
position: absolute;
top: 8rem;
left: 33rem;
}
#winegrid {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 1rem;
grid-auto-rows: minmax(100px, auto);
width: 85%;
margin: 60px auto;
}
article {
width: 80%;
padding: 30px;
}
article .wineImage {
width: 50%;
margin: 0 auto 20px auto;
display: block;
}
article .name {
font-size: 1.4rem;
font-weight: 400;
margin-top: 5px;
}
article .wineHouse {
font-size: 1.1em;
font-weight: 100;
margin-top: 4px;
}
article .area {
font-size: 1.1rem;
font-weight: 100;
margin-top: 1px;
}
article .rating {
font-size: 2rem;
margin: 40px 0 5px 0;
}
article .ratingImage {
width: 30%;
}
/* DESKTOP WINE PAGE ENDS HERE*/
/* DESKTOP ABOUT ME PAGE STARTS HERE */
.about-me-box {
width: 50%;
top: 15rem;
left: 26rem
}
.about-me-box hr{
margin: 0 auto;
}
.about-me-box h1 {
font-size: 2.6rem;
padding-top: 10px;
}
.about-me-box p {
padding: 3% 10% 5% 10%;
font-size: 1.3rem;
line-height: 1.7rem;
}
/* DESKTOP ABOUT ME PAGE ENDS HERE */
/* DESKTOP FOOTER STARTS HERE */
footer {
height: 7vh;
text-align: right;
padding: 30px 20px;
}
.footer_1p {
font-size: 1.2rem;
}
.footer_2p {
font-size: 1rem;
margin-top: 18px;
}
/* DESKTOP FOOTER STARTS HERE */
}
const template = document.querySelector("#myTemp").content;
let vh = window.innerHeight * 0.01;
const productListLink = "https://spreadsheets.google.com/feeds/list/1s4CkxsGQ93Ro5fkyjGdEvRgaVLmF0CYVSIldWqDIcv0/od6/public/values?alt=json";
function loadJSON(link) {
console.log(link);
fetch(link).then(e=>e.json()).then(data=>data.feed.entry.forEach(displayWineData))
}
let count=0;
function displayWineData(product) {
console.log(product)
// const section = document.querySelector("#" + product.category)
let clone = template.cloneNode(true);
clone.querySelector(".wineWrapper", "#myBtn").id+=count;
clone.querySelector(".wineImage").src = product.gsx$wineimage.$t;
//clone.querySelector("img").alt = product.image;
clone.querySelector(".name").textContent = product.gsx$name.$t;
clone.querySelector(".wineHouse").textContent = product.gsx$house.$t;
clone.querySelector(".area").textContent = product.gsx$region.$t;
clone.querySelector(".rating").textContent = product.gsx$rating.$t;
clone.querySelector(".ratingImage").src = product.gsx$ratingimage.$t;
clone.querySelector(".modal", "#myModal");
clone.querySelector(".modal-content");
clone.querySelector(".wineDescription").textContent = product.gsx$description.$t;
clone.querySelector(".close");
clone.querySelector(".wineWrapper", "#myBtn"+count).onclick= function(e) {
this.nextElementSibling.style.display = "block";
}
clone.querySelector(".close").onclick=function(){
this.parentNode.parentNode.style.display = "none";
}
document.querySelector("#winegrid").appendChild(clone)
count++;
};
loadJSON(productListLink)
// Here I set the height for the gloabal --vh to match each vieport height
document.documentElement.style.setProperty('--vh', `${vh}px`);
//
//template.onclick = function() {
// modal.style.display = "block";
//}
Also see: Tab Triggers