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.
<section>
<div class="container flow-content">
<h2 class="section-title">Meet the team</h2>
<ul role="list" class="grid">
<li>
<article class="card" data-visible="false">
<div class="card__front flow-content">
<img class="card__img mx-auto" src="https://images.unsplash.com/photo-1599566150163-29194dcaad36?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2ODUwMjU1ODF8&ixlib=rb-4.0.3&q=80&w=400" alt="John Smith (from Unsplash)" />
<div class="flow-content" data-spacing="sm">
<p class="card__name">John Smith</p>
<p class="card__position">Project Manager</p>
</div>
</div>
<div class="card__back flow-content">
<p class="card__name">John Smith</p>
<q>Success is a team effort, and I'm proud to be part of this incredible team.</q>
<ul role="list" class="card__social flex-group">
<li>
<a href="#">
<i class="fa-brands fa-twitter fa-xl"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa-brands fa-linkedin fa-xl"></i>
</a>
</li>
</ul>
</div>
<footer class="card__footer">
<button data-card-controller class="card__toggle">
<i class="fa-solid fa-plus card__toggle-icon"></i>
</button>
</footer>
</article>
</li>
<li>
<article class="card" data-visible="false">
<div class="card__front flow-content">
<img class="card__img mx-auto" src="https://images.unsplash.com/photo-1539571696357-5a69c17a67c6?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2ODUwMzAxNzB8&ixlib=rb-4.0.3&q=80&w=400" alt="John Smith (from Unsplash)" />
<div class="flow-content" data-spacing="sm">
<p class="card__name">Michael Thompson</p>
<p class="card__position">Marketing Specialist</p>
</div>
</div>
<div class="card__back flow-content">
<p class="card__name">Michael Thompson</p>
<q>I believe in the power of storytelling to connect brands with their audience.</q>
<ul role="list" class="card__social flex-group">
<li>
<a href="#">
<i class="fa-brands fa-twitter fa-xl"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa-brands fa-linkedin fa-xl"></i>
</a>
</li>
</ul>
</div>
<footer class="card__footer">
<button data-card-controller class="card__toggle">
<i class="fa-solid fa-plus card__toggle-icon"></i>
</button>
</footer>
</article>
</li>
<li>
<article class="card" data-visible="false">
<div class="card__front flow-content">
<img class="card__img mx-auto" src="https://images.unsplash.com/photo-1580489944761-15a19d654956?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2ODUwMzAyODV8&ixlib=rb-4.0.3&q=80&w=400" alt="John Smith (from Unsplash)" />
<div class="flow-content" data-spacing="sm">
<p class="card__name">Jessica Lee</p>
<p class="card__position">Sales Manager</p>
</div>
</div>
<div class="card__back flow-content">
<p class="card__name">Jessica Lee</p>
<q>Building strong relationships with clients is at the heart of my approach to sales.</q>
<ul role="list" class="card__social flex-group">
<li>
<a href="#">
<i class="fa-brands fa-twitter fa-xl"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa-brands fa-linkedin fa-xl"></i>
</a>
</li>
</ul>
</div>
<footer class="card__footer">
<button data-card-controller class="card__toggle">
<i class="fa-solid fa-plus card__toggle-icon"></i>
</button>
</footer>
</article>
</li>
<li>
<article class="card" data-visible="false">
<div class="card__front flow-content">
<img class="card__img mx-auto" src="https://images.unsplash.com/photo-1540569014015-19a7be504e3a?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2ODUwMjU1ODF8&ixlib=rb-4.0.3&q=80&w=400" alt="John Smith (from Unsplash)" />
<div class="flow-content" data-spacing="sm">
<p class="card__name">Mark Johnson</p>
<p class="card__position">Software Engineer</p>
</div>
</div>
<div class="card__back flow-content">
<p class="card__name">Mark Johnson</p>
<q>I believe in pushing the boundaries of technology to create innovative solutions for our users.</q>
<ul role="list" class="card__social flex-group">
<li>
<a href="#">
<i class="fa-brands fa-twitter fa-xl"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa-brands fa-linkedin fa-xl"></i>
</a>
</li>
</ul>
</div>
<footer class="card__footer">
<button data-card-controller class="card__toggle">
<i class="fa-solid fa-plus card__toggle-icon"></i>
</button>
</footer>
</article>
</li>
<li>
<article class="card" data-visible="false">
<div class="card__front flow-content">
<img class="card__img mx-auto" src="https://images.unsplash.com/photo-1552058544-f2b08422138a?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2ODUwMzAyMjl8&ixlib=rb-4.0.3&q=80&w=400" alt="John Smith (from Unsplash)" />
<div class="flow-content" data-spacing="sm">
<p class="card__name">Michael Thompson</p>
<p class="card__position">Graphic Designer</p>
</div>
</div>
<div class="card__back flow-content">
<p class="card__name">Michael Thompson</p>
<q>Design is all about finding beauty in simplicity, and I love bringing ideas to life.</q>
<ul role="list" class="card__social flex-group">
<li>
<a href="#">
<i class="fa-brands fa-twitter fa-xl"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa-brands fa-linkedin fa-xl"></i>
</a>
</li>
</ul>
</div>
<footer class="card__footer">
<button data-card-controller class="card__toggle">
<i class="fa-solid fa-plus card__toggle-icon"></i>
</button>
</footer>
</article>
</li>
<li>
<article class="card" data-visible="false">
<div class="card__front flow-content">
<img class="card__img mx-auto" src="https://images.unsplash.com/photo-1615813967515-e1838c1c5116?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE2ODUwMzAyMjl8&ixlib=rb-4.0.3&q=80&w=400" alt="John Smith (from Unsplash)" />
<div class="flow-content" data-spacing="sm">
<p class="card__name">David Wilson</p>
<p class="card__position">Junior Developer</p>
</div>
</div>
<div class="card__back flow-content">
<p class="card__name">David Wilson</p>
<q>Coding is my passion, and I'm excited to contribute my skills to this project.</q>
<ul role="list" class="card__social flex-group">
<li>
<a href="#">
<i class="fa-brands fa-twitter fa-xl"></i>
</a>
</li>
<li>
<a href="#">
<i class="fa-brands fa-linkedin fa-xl"></i>
</a>
</li>
</ul>
</div>
<footer class="card__footer">
<button data-card-controller class="card__toggle">
<i class="fa-solid fa-plus card__toggle-icon"></i>
</button>
</footer>
</article>
</li>
</ul>
</div>
</section>
:root {
--clr-primary: teal;
--clr-secondary: crimson;
--bg-primary: #0d1a2d;
--bg-secondary: #14273e;
--text-primary: #fff;
--text-secondary: #ccc;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
* {
margin: 0;
font: inherit;
}
html {
color-scheme: dark;
}
body {
font-family: system-ui, sans-serif;
min-height: 100vh;
background-color: var(--bg-primary);
color: var(--text-secondary);
}
ul:where([role="list"]) {
list-style: none;
margin: 0;
padding: 0;
}
section {
padding-block: clamp(2rem, 5vw, 5rem);
}
a {
color: cyan;
text-decoration: none;
}
.container {
width: min(100% - 2rem, 65rem);
margin-inline: auto;
}
.grid {
display: grid;
gap: 1.5rem;
grid-template-columns:
repeat(auto-fit, minmax(min(35ch, 100%), 1fr));
}
.section-title {
font-size: clamp(2rem, 5vw, 3rem);
text-align: center;
font-weight: bold;
color: var(--text-primary);
margin-bottom: 0.5em;
}
.flex-group {
display: flex;
gap: 1rem;
flex-wrap: wrap;
align-items: center;
}
.flow-content {
display: grid;
align-content: start;
gap: 1rem;
}
[data-spacing="sm"] {
gap: 0.25rem;
}
.mx-auto {
width: fit-content;
margin-inline: auto;
}
/* starts here */
.card {
display: grid;
gap: 0.5rem;
position: relative;
overflow: hidden;
width: min(100% - 2rem, 35ch);
margin-inline: auto;
border-radius: 0.5rem;
background-color: var(--bg-secondary);
text-align: center;
}
.card__name {
font-weight: 700;
color: var(--text-primary);
}
.card__position {
font-style: italic;
}
.card__img {
width: 5rem;
aspect-ratio: 1 / 1;
object-fit: cover;
border-radius: 50%;
border: 2px solid var(--text-secondary);
}
.card__front {
padding: 2em 2em 2.5em 2em;
transition:
opacity 250ms ease,
transform 450ms ease;
}
.card[data-visible="false"] .card__front {
opacity: 1;
transform: translateY(0);
}
.card__footer {
position: relative;
height: 1.5rem;
background-color: var(--bg-primary);
z-index: 5;
}
.card__back {
position: absolute;
padding: 2em 2em 2.5em 2em;
inset: 0;
transition:
transform 450ms ease,
opacity 150ms ease;
z-index: 1;
overflow: auto;
}
.card[data-visible="false"] .card__back {
opacity: 0;
transform: translateY(100%);
}
.card[data-visible="true"] .card__front {
opacity: 0;
transform: translateY(100%);
transition:
opacity 150ms ease,
transform 450ms ease 50ms;
}
.card[data-visible="true"] .card__back {
opacity: 1;
transform: translateY(0);
transition:
transform 350ms ease,
opacity 450ms ease 100ms;
}
.card__social {
justify-content: center;
margin-bottom: 2em;
}
.card__toggle {
text-align: 1;
border-radius: 50%;
width: 3rem;
aspect-ratio: 1 / 1;
padding: 0.5em;
border: 0;
background-color: var(--clr-primary);
color: var(--text-primary);
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
cursor: pointer;
transition: background-color 250ms ease;
}
.card__toggle-icon {
transition: rotate 250ms ease;
}
.card[data-visible="true"] .card__toggle {
background-color: var(--clr-secondary);
}
.card[data-visible="true"] .card__toggle-icon {
rotate: 315deg;
}
// Inspiration - Frontend Mentor
// https://www.frontendmentor.io/challenges/myteam-multipage-website-mxlEauvW
const cardControllers = document.querySelectorAll("[data-card-controller]");
cardControllers.forEach(controller => {
controller.addEventListener("click", (e) => {
const card = e.currentTarget.parentElement.parentElement;
const isVisible = card.dataset.visible;
if (isVisible === "false") {
card.setAttribute("data-visible", true);
} else {
card.setAttribute("data-visible", false);
}
})
})
Also see: Tab Triggers