<div class="container">
<div class="counter-reset">
<h1 data-element="h1">Counter-increment</h1>
<p data-element="p">Paragraph...</p>
<aside data-element="aside">
Aside...
<p data-element="p">Paragraph...</p>
<p data-element="p">Paragraph...</p>
</aside>
<p data-element="p">Paragraph...</p>
<section data-element="section">
Section...
<p data-element="p">Paragraph...</p>
<p data-element="p">Paragraph...</p>
</section>
</div>
</div>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");
* {
box-sizing: border-box;
}
body {
inline-size: 100vw;
min-block-size: 100vh;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
/* align-items: center; */
gap: 10px;
font-family: "Exo", Arial, sans-serif;
background-color: #f7f7f7;
line-height: 2;
padding: 20px;
}
.container {
padding: 10px 20px;
background: #fff;
box-sizing: border-box;
box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
min-width: 50vw;
border-radius: 5px;
position: relative;
width: 80%;
max-width: 60vw;
flex: 1;
}
.counter-reset > * {
margin: 10px 0;
}
section,
aside {
border-right: 5px solid;
}
section > p,
aside > p {
margin-left: 3em;
}
.counter-reset *::before {
display: inline-flex;
color: #fff;
background-color: #f36;
padding: 10px;
line-height: 1;
font-size: 2rem;
margin-right: 20px;
aspect-ratio: 1 / 1;
justify-content: center;
align-items: center;
clip-path: polygon(
0% 0%,
89% 0,
89% 40%,
100% 50%,
89% 61%,
88% 100%,
0 100%
);
border-radius: 50%;
}
section p::before {
background: #09f !important;
font-size: 100% !important;
}
aside p::before {
background: #98f !important;
font-size: 100% !important;
}
.counter-reset *::after {
content: "(" attr(data-element) " Element)";
font-size: 85%;
line-height: 1;
color: #5c2;
margin-left: 5px;
}
.form {
background: rgb(0 0 0 / 0.8);
color: #fff;
padding: 50px 10px 10px;
display: flex;
flex-direction: column;
justify-content: flex-start;
gap: 10px;
text-shadow: 1px 1px 0 rgb(255 125 125 / 0.8);
}
label {
display: inline-flex;
align-items: center;
gap: 5px;
cursor: pointer;
}
.counter-reset {
counter-reset: level1 level2-1 level2-2;
}
.counter-reset > :not(h1) {
counter-increment: level1;
}
section p {
counter-increment: level2-1;
}
aside p {
counter-increment: level2-2;
}
.counter-reset > :not(h1)::before {
content: counter(level1);
}
section p::before {
content: counter(level1) "." counter(level2-1);
}
aside p::before {
content: counter(level1) "." counter(level2-2);
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.