Comic callout sections
<div class="callout callout-info">Additional information that you may want to know.</div>
<div class="callout callout-warning">Warn about something happening if you do this.</div>
<div class="callout callout-error">Something bad will happen if you do this.</div> @font-face {
font-family: "Playpen Sans";
font-weight: 500;
src: url("PlaypenSans-Medium.woff2");
}
body {
min-height: 100dvh;
margin: 0;
background: hsl(214, 40%, 70%);
display: flex;
flex-direction: column;
justify-content: space-evenly;
align-items: center;
}
/* The default callout style is "information" with green colours. */
.callout {
--bg-color: hsl(130, 80%, 64%);
--dot-color: hsl(130, 80%, 48%);
--border-color: hsl(130, 80%, 34%);
--dot-size: 0.05rem;
--dot-density: 0.5rem;
--dot-positioning: 0 0, 0.25rem 0.25rem;
width: 80%;
max-width: 600px;
padding: 0.75rem 0.5rem;
position: relative;
font-family: "Playpen Sans", cursive;
font-weight: 500;
font-size: 1.25rem;
color: hsl(279, 100%, 10%);
background-color: var(--bg-color);
background-image: radial-gradient(
var(--dot-color) var(--dot-size),
transparent var(--dot-size)
),
radial-gradient(var(--dot-color) var(--dot-size), transparent var(--dot-size));
background-size: var(--dot-density) var(--dot-density);
background-position: var(--dot-positioning);
border: 1px solid var(--border-color);
}
.callout-warning {
--bg-color: hsl(35, 100%, 64%);
--dot-color: hsl(35, 100%, 48%);
--border-color: hsl(35, 100%, 34%);
}
.callout-error {
--bg-color: hsl(6, 100%, 64%);
--dot-color: hsl(6, 100%, 48%);
--border-color: hsl(6, 100%, 34%);
}
/* This adds a label to indicate the type of callout. It is visually hidden but here to improve accessibility */
.callout::before {
content: "information";
display: block;
/* hidden. Here to make accessibile. */
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
border: 0;
padding: 0;
white-space: nowrap;
clip-path: inset(100%);
clip: rect(0 0 0 0);
overflow: hidden;
}
.callout-warning::before {
content: "warning";
}
.callout-error::before {
content: "error";
}
/* This is a darker, offset version of the main element that acts as type of box-shadow. This is
used over `box-shadow` because I want this element to have a stipled background also */
.callout::after {
content: "";
--bg-color: hsl(42, 5%, 10%);
--dot-color: hsl(42, 5%, 17%);
--dot-size: 0.05rem;
--dot-density: 0.5rem;
--dot-positioning: 0 0, 0.25rem 0.25rem;
display: block;
width: calc(100% + 0.5rem);
height: calc(100% + 0.5rem);
position: absolute;
top: 0.25rem;
left: 0.25rem;
background-color: var(--bg-color);
background-image: radial-gradient(
var(--dot-color) var(--dot-size),
transparent var(--dot-size)
),
radial-gradient(var(--dot-color) var(--dot-size), transparent var(--dot-size));
background-size: var(--dot-density) var(--dot-density);
background-position: var(--dot-positioning);
z-index: -1;
} Description
I wanted to experiment with callouts (callout sections). A callout is a short piece of text or graphic that highlights important information. I wanted to infuse them with the half-tone style of comics. The background has that stippling effect with offset dots.
The colours used indicate the type of information being communicated. Green is informational, orange is warning, and red is things that can led to serious errors. The ::before psuedo-element provides a label to make them accessible to all.