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.
<aside>
<h1>Logo</h1>
<nav>
<a href="">CSS</a>
<a href="">HTML</a>
<a href="">JavaScript</a>
<a href="">React</a>
<a href="">Vue</a>
</nav>
</aside>
<main>
<div class="section">
<div class="section__heading">
<h3 class="section__title">爆款直降</h3>
</div>
<div class="section__body">
<ul class="cards">
<li class="card">
<div class="card__media">
<img src="https://picsum.photos/222/?random=11" alt="">
<div class="card__badge">年货节</div>
</div>
<div class="card__content">
<div class="card__heading">
<h4 class="card__title">卡片标题卡片标题</h4>
</div>
<div class="card__des">口味清爽,最多八个字</div>
<div class="card__action">
<div class="card__price">
<span>¥</span>
<strong>32</strong>
</div>
<div class="card__link">
<svg t="1639970508640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9201" width="200" height="200">
<path d="M398.933333 326.4l168.533334 168.533333-168.533334 168.533334c-14.933333 14.933333-14.933333 38.4 0 53.333333s38.4 14.933333 53.333334 0l196.266666-196.266667c14.933333-14.933333 14.933333-38.4 0-53.333333l-196.266666-196.266667c-14.933333-14.933333-38.4-14.933333-53.333334 0s-14.933333 40.533333 0 55.466667zM512 981.333333C251.733333 981.333333 42.666667 772.266667 42.666667 512S251.733333 42.666667 512 42.666667s469.333333 209.066667 469.333333 469.333333-209.066667 469.333333-469.333333 469.333333z" p-id="9202" fill="currentColor"></path>
</svg>
</div>
</div>
</div>
</li>
<li class="card">
<div class="card__media">
<img src="https://picsum.photos/222/?random=23" alt="">
<div class="card__badge">年货节</div>
</div>
<div class="card__content">
<div class="card__heading">
<h4 class="card__title">卡片标题卡片标题</h4>
</div>
<div class="card__des">口味清爽,最多八个字</div>
<div class="card__action">
<div class="card__price">
<span>¥</span>
<strong>32</strong>
</div>
<div class="card__link">
<svg t="1639970508640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9201" width="200" height="200">
<path d="M398.933333 326.4l168.533334 168.533333-168.533334 168.533334c-14.933333 14.933333-14.933333 38.4 0 53.333333s38.4 14.933333 53.333334 0l196.266666-196.266667c14.933333-14.933333 14.933333-38.4 0-53.333333l-196.266666-196.266667c-14.933333-14.933333-38.4-14.933333-53.333334 0s-14.933333 40.533333 0 55.466667zM512 981.333333C251.733333 981.333333 42.666667 772.266667 42.666667 512S251.733333 42.666667 512 42.666667s469.333333 209.066667 469.333333 469.333333-209.066667 469.333333-469.333333 469.333333z" p-id="9202" fill="currentColor"></path>
</svg>
</div>
</div>
</div>
</li>
<li class="card">
<div class="card__media">
<img src="https://picsum.photos/222/?random=32" alt="">
<div class="card__badge">年货节</div>
</div>
<div class="card__content">
<div class="card__heading">
<h4 class="card__title">卡片标题卡片标题</h4>
</div>
<div class="card__des">口味清爽,最多八个字</div>
<div class="card__action">
<div class="card__price">
<span>¥</span>
<strong>32</strong>
</div>
<div class="card__link">
<svg t="1639970508640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9201" width="200" height="200">
<path d="M398.933333 326.4l168.533334 168.533333-168.533334 168.533334c-14.933333 14.933333-14.933333 38.4 0 53.333333s38.4 14.933333 53.333334 0l196.266666-196.266667c14.933333-14.933333 14.933333-38.4 0-53.333333l-196.266666-196.266667c-14.933333-14.933333-38.4-14.933333-53.333334 0s-14.933333 40.533333 0 55.466667zM512 981.333333C251.733333 981.333333 42.666667 772.266667 42.666667 512S251.733333 42.666667 512 42.666667s469.333333 209.066667 469.333333 469.333333-209.066667 469.333333-469.333333 469.333333z" p-id="9202" fill="currentColor"></path>
</svg>
</div>
</div>
</div>
</li>
<li class="card">
<div class="card__media">
<img src="https://picsum.photos/222/?random=1" alt="">
<div class="card__badge">年货节</div>
</div>
<div class="card__content">
<div class="card__heading">
<h4 class="card__title">卡片标题卡片标题</h4>
</div>
<div class="card__des">口味清爽,最多八个字</div>
<div class="card__action">
<div class="card__price">
<span>¥</span>
<strong>32</strong>
</div>
<div class="card__link">
<svg t="1639970508640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9201" width="200" height="200">
<path d="M398.933333 326.4l168.533334 168.533333-168.533334 168.533334c-14.933333 14.933333-14.933333 38.4 0 53.333333s38.4 14.933333 53.333334 0l196.266666-196.266667c14.933333-14.933333 14.933333-38.4 0-53.333333l-196.266666-196.266667c-14.933333-14.933333-38.4-14.933333-53.333334 0s-14.933333 40.533333 0 55.466667zM512 981.333333C251.733333 981.333333 42.666667 772.266667 42.666667 512S251.733333 42.666667 512 42.666667s469.333333 209.066667 469.333333 469.333333-209.066667 469.333333-469.333333 469.333333z" p-id="9202" fill="currentColor"></path>
</svg>
</div>
</div>
</div>
</li>
<li class="card">
<div class="card__media">
<img src="https://picsum.photos/222/?random=2" alt="">
<div class="card__badge">年货节</div>
</div>
<div class="card__content">
<div class="card__heading">
<h4 class="card__title">卡片标题卡片标题</h4>
</div>
<div class="card__des">口味清爽,最多八个字</div>
<div class="card__action">
<div class="card__price">
<span>¥</span>
<strong>32</strong>
</div>
<div class="card__link">
<svg t="1639970508640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9201" width="200" height="200">
<path d="M398.933333 326.4l168.533334 168.533333-168.533334 168.533334c-14.933333 14.933333-14.933333 38.4 0 53.333333s38.4 14.933333 53.333334 0l196.266666-196.266667c14.933333-14.933333 14.933333-38.4 0-53.333333l-196.266666-196.266667c-14.933333-14.933333-38.4-14.933333-53.333334 0s-14.933333 40.533333 0 55.466667zM512 981.333333C251.733333 981.333333 42.666667 772.266667 42.666667 512S251.733333 42.666667 512 42.666667s469.333333 209.066667 469.333333 469.333333-209.066667 469.333333-469.333333 469.333333z" p-id="9202" fill="currentColor"></path>
</svg>
</div>
</div>
</div>
</li>
<li class="card">
<div class="card__media">
<img src="https://picsum.photos/222/?random=3" alt="">
<div class="card__badge">年货节</div>
</div>
<div class="card__content">
<div class="card__heading">
<h4 class="card__title">卡片标题卡片标题</h4>
</div>
<div class="card__des">口味清爽,最多八个字</div>
<div class="card__action">
<div class="card__price">
<span>¥</span>
<strong>32</strong>
</div>
<div class="card__link">
<svg t="1639970508640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9201" width="200" height="200">
<path d="M398.933333 326.4l168.533334 168.533333-168.533334 168.533334c-14.933333 14.933333-14.933333 38.4 0 53.333333s38.4 14.933333 53.333334 0l196.266666-196.266667c14.933333-14.933333 14.933333-38.4 0-53.333333l-196.266666-196.266667c-14.933333-14.933333-38.4-14.933333-53.333334 0s-14.933333 40.533333 0 55.466667zM512 981.333333C251.733333 981.333333 42.666667 772.266667 42.666667 512S251.733333 42.666667 512 42.666667s469.333333 209.066667 469.333333 469.333333-209.066667 469.333333-469.333333 469.333333z" p-id="9202" fill="currentColor"></path>
</svg>
</div>
</div>
</div>
</li>
<li class="card">
<div class="card__media">
<img src="https://picsum.photos/222/?random=43" alt="">
<div class="card__badge">年货节</div>
</div>
<div class="card__content">
<div class="card__heading">
<h4 class="card__title">卡片标题卡片标题</h4>
</div>
<div class="card__des">口味清爽,最多八个字</div>
<div class="card__action">
<div class="card__price">
<span>¥</span>
<strong>32</strong>
</div>
<div class="card__link">
<svg t="1639970508640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9201" width="200" height="200">
<path d="M398.933333 326.4l168.533334 168.533333-168.533334 168.533334c-14.933333 14.933333-14.933333 38.4 0 53.333333s38.4 14.933333 53.333334 0l196.266666-196.266667c14.933333-14.933333 14.933333-38.4 0-53.333333l-196.266666-196.266667c-14.933333-14.933333-38.4-14.933333-53.333334 0s-14.933333 40.533333 0 55.466667zM512 981.333333C251.733333 981.333333 42.666667 772.266667 42.666667 512S251.733333 42.666667 512 42.666667s469.333333 209.066667 469.333333 469.333333-209.066667 469.333333-469.333333 469.333333z" p-id="9202" fill="currentColor"></path>
</svg>
</div>
</div>
</div>
</li>
<li class="card">
<div class="card__media">
<img src="https://picsum.photos/222/?random=35" alt="">
<div class="card__badge">年货节</div>
</div>
<div class="card__content">
<div class="card__heading">
<h4 class="card__title">卡片标题卡片标题</h4>
</div>
<div class="card__des">口味清爽,最多八个字</div>
<div class="card__action">
<div class="card__price">
<span>¥</span>
<strong>32</strong>
</div>
<div class="card__link">
<svg t="1639970508640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9201" width="200" height="200">
<path d="M398.933333 326.4l168.533334 168.533333-168.533334 168.533334c-14.933333 14.933333-14.933333 38.4 0 53.333333s38.4 14.933333 53.333334 0l196.266666-196.266667c14.933333-14.933333 14.933333-38.4 0-53.333333l-196.266666-196.266667c-14.933333-14.933333-38.4-14.933333-53.333334 0s-14.933333 40.533333 0 55.466667zM512 981.333333C251.733333 981.333333 42.666667 772.266667 42.666667 512S251.733333 42.666667 512 42.666667s469.333333 209.066667 469.333333 469.333333-209.066667 469.333333-469.333333 469.333333z" p-id="9202" fill="currentColor"></path>
</svg>
</div>
</div>
</div>
</li>
<li class="card">
<div class="card__media">
<img src="https://picsum.photos/222/?random=36" alt="">
<div class="card__badge">年货节</div>
</div>
<div class="card__content">
<div class="card__heading">
<h4 class="card__title">卡片标题卡片标题</h4>
</div>
<div class="card__des">口味清爽,最多八个字</div>
<div class="card__action">
<div class="card__price">
<span>¥</span>
<strong>32</strong>
</div>
<div class="card__link">
<svg t="1639970508640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9201" width="200" height="200">
<path d="M398.933333 326.4l168.533334 168.533333-168.533334 168.533334c-14.933333 14.933333-14.933333 38.4 0 53.333333s38.4 14.933333 53.333334 0l196.266666-196.266667c14.933333-14.933333 14.933333-38.4 0-53.333333l-196.266666-196.266667c-14.933333-14.933333-38.4-14.933333-53.333334 0s-14.933333 40.533333 0 55.466667zM512 981.333333C251.733333 981.333333 42.666667 772.266667 42.666667 512S251.733333 42.666667 512 42.666667s469.333333 209.066667 469.333333 469.333333-209.066667 469.333333-469.333333 469.333333z" p-id="9202" fill="currentColor"></path>
</svg>
</div>
</div>
</div>
</li>
<li class="card">
<div class="card__media">
<img src="https://picsum.photos/222/?random=63" alt="">
<div class="card__badge">年货节</div>
</div>
<div class="card__content">
<div class="card__heading">
<h4 class="card__title">卡片标题卡片标题</h4>
</div>
<div class="card__des">口味清爽,最多八个字</div>
<div class="card__action">
<div class="card__price">
<span>¥</span>
<strong>32</strong>
</div>
<div class="card__link">
<svg t="1639970508640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9201" width="200" height="200">
<path d="M398.933333 326.4l168.533334 168.533333-168.533334 168.533334c-14.933333 14.933333-14.933333 38.4 0 53.333333s38.4 14.933333 53.333334 0l196.266666-196.266667c14.933333-14.933333 14.933333-38.4 0-53.333333l-196.266666-196.266667c-14.933333-14.933333-38.4-14.933333-53.333334 0s-14.933333 40.533333 0 55.466667zM512 981.333333C251.733333 981.333333 42.666667 772.266667 42.666667 512S251.733333 42.666667 512 42.666667s469.333333 209.066667 469.333333 469.333333-209.066667 469.333333-469.333333 469.333333z" p-id="9202" fill="currentColor"></path>
</svg>
</div>
</div>
</div>
</li>
<li class="card">
<div class="card__media">
<img src="https://picsum.photos/222/?random=38" alt="">
<div class="card__badge">年货节</div>
</div>
<div class="card__content">
<div class="card__heading">
<h4 class="card__title">卡片标题卡片标题</h4>
</div>
<div class="card__des">口味清爽,最多八个字</div>
<div class="card__action">
<div class="card__price">
<span>¥</span>
<strong>32</strong>
</div>
<div class="card__link">
<svg t="1639970508640" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9201" width="200" height="200">
<path d="M398.933333 326.4l168.533334 168.533333-168.533334 168.533334c-14.933333 14.933333-14.933333 38.4 0 53.333333s38.4 14.933333 53.333334 0l196.266666-196.266667c14.933333-14.933333 14.933333-38.4 0-53.333333l-196.266666-196.266667c-14.933333-14.933333-38.4-14.933333-53.333334 0s-14.933333 40.533333 0 55.466667zM512 981.333333C251.733333 981.333333 42.666667 772.266667 42.666667 512S251.733333 42.666667 512 42.666667s469.333333 209.066667 469.333333 469.333333-209.066667 469.333333-469.333333 469.333333z" p-id="9202" fill="currentColor"></path>
</svg>
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
</main>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100vw;
min-height: 100vh;
background-color: #557;
width: 100vw;
min-height: 100vh;
font-family: "Exo", Arial, sans-serif;
line-height: 1.5;
background-color: #557;
}
img {
max-width: 100%;
height: auto;
vertical-align: top;
}
svg {
width: 1em;
height: 1em;
}
ul {
list-style: none outside none;
}
main,
aside {
background-color: #f4f4f4;
}
.section {
display: flex;
flex-direction: column;
padding: 24px;
overflow: hidden;
resize: horizontal;
}
.section__heading {
display: flex;
align-items: center;
color: #333;
margin-bottom: 24px;
}
.section__title {
font-size: 32px;
font-weight: 500;
}
.cards {
--gap: 18px;
--minwidth: 220px;
display: grid;
grid-template-columns: repeat(
auto-fit,
minmax(min(100%, var(--minwidth)), 1fr)
);
gap: var(--gap);
}
.card {
background-color: #fff;
border-radius: 12px;
display: flex;
flex-direction: column;
}
.card__media {
position: relative;
border-radius: 12px 12px 0 0;
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 20px;
padding: 14px;
min-height: 220px;
}
.card__media .card__badge {
position: absolute;
background-image: linear-gradient(90deg, #ff5000 0%, #ff0552 99%);
border-radius: 4px;
color: #fff;
display: inline-flex;
justify-content: center;
align-items: center;
padding: 2px 4px;
font-size: 20px;
font-weight: 700;
line-height: 1;
left: 14px;
bottom: -12px;
}
.card__content {
display: flex;
flex-direction: column;
padding: 0 14px 24px;
}
.card__title {
font-weight: 500;
font-size: 24px;
color: #333333;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 8px;
}
.card__des {
max-width: 8em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 20px;
color: #ba9663;
margin-bottom: 18px;
}
.card__action {
display: flex;
align-items: center;
justify-content: space-between;
font-weight: 500;
font-size: 32px;
color: #ff5000;
line-height: 1;
}
.card__price {
display: inline-flex;
align-items: flex-end;
}
.card__price span {
font-weight: normal;
font-size: 24px;
position: relative;
bottom: 0.125em;
}
.card__link {
font-size: 32px;
font-weight: normal;
display: inline-flex;
justify-content: center;
align-items: center;
}
aside {
padding: 2rem 1.5rem;
display: flex;
flex-direction: column;
gap: 20px;
}
aside h1 {
margin: 0;
}
nav {
display: grid;
gap: 10px;
grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
}
nav a {
display: block;
padding: 10px 0;
text-decoration: none;
font-size: clamp(1rem, 1.25rem + 2vw, 1.5rem);
}
body {
display: grid;
gap: 1rem;
grid-template-areas:
"sidebar"
"main";
}
@media (min-width: 768px) {
body {
grid-template-columns: fit-content(250px) 1fr;
grid-template-areas: "sidebar main";
}
}
aside {
grid-area: sidebar;
}
main {
grid-area: main;
}
Also see: Tab Triggers