Skip to content

Instantly share code, notes, and snippets.

@mbutler
Created July 14, 2025 21:36
Show Gist options
  • Select an option

  • Save mbutler/f4189cd02bed20aa8f4b09bd4c25aa26 to your computer and use it in GitHub Desktop.

Select an option

Save mbutler/f4189cd02bed20aa8f4b09bd4c25aa26 to your computer and use it in GitHub Desktop.
4e styling
/*
* D&D 4e Style Sheet - Universal 4e Block Styling
* Combines and adapts styles from the project's CSS library
* For use with any D&D 4e code block: powers, monsters, items, etc.
*/
:root {
--font-primary: 'DragonBodySans', Arial, sans-serif;
--font-secondary: 'DragonBodySerif', Georgia, serif;
--background-atwill: #619769;
--background-encounter: #961334;
--background-daily: #4d4d4f;
--background-recharge: #70774f;
--background-other: #193d5e;
--background-item: #d7941d;
--background-npc: #4e5c2e;
--gradient-4e: linear-gradient(270deg, #fff 0%, #dddcbb 100%);
--gradient-4e-item: linear-gradient(90deg, #eed4ad 0%, #fff 100%);
--background-container: #fff;
--colour-text-inside: #484a3d;
--color-text-dark-primary: #000;
--color-text-light-primary: #fff;
--background-row-odd: #d3d1ba;
--background-row-even: var(--gradient-4e);
--border-main: 2px solid #b3a079;
}
.dnd4e-block {
font-family: var(--font-primary);
background: var(--gradient-4e);
border: var(--border-main);
border-radius: 8px;
box-shadow: 0 2px 8px #0002;
padding: 1.2em 1.5em;
margin: 2em auto;
max-width: 540px;
color: var(--color-text-dark-primary);
}
.dnd4e-block .flavour, .dnd4e-block .flavor {
font-style: italic;
background: var(--gradient-4e);
padding: 0.3em 0.6em;
border-radius: 4px;
margin-bottom: 0.5em;
color: #333;
display: block;
}
.dnd4e-block .power-basics {
background: #fff;
font-weight: bold;
padding: 0.2em 0.6em;
border-radius: 4px;
margin-bottom: 0.3em;
color: #222;
display: inline-block;
box-shadow: 0 1px 2px #0001;
}
.dnd4e-block p {
margin: 0.4em 0;
padding: 0.1em 0.3em;
background: #fff8;
border-radius: 3px;
}
.dnd4e-block p b, .dnd4e-block p strong {
color: #222;
}
.dnd4e-block .power-basics + .power-basics {
margin-left: 0.5em;
}
/* Monster stat block table styles */
.dnd4e-block table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
margin: 1em 0 0.5em 0;
background: #e8e6d4;
border-radius: 6px;
overflow: hidden;
box-shadow: 0 1px 4px #0001;
}
.dnd4e-block table tr {
border-bottom: 1px solid #cdcbb5;
}
.dnd4e-block table tr:last-child {
border-bottom: none;
}
.dnd4e-block table td, .dnd4e-block table th {
padding: 0.4em 0.7em;
font-size: 1em;
vertical-align: top;
border-right: 1px solid #cdcbb5;
}
.dnd4e-block table td:last-child, .dnd4e-block table th:last-child {
border-right: none;
}
.dnd4e-block table b, .dnd4e-block table strong {
color: #4e5c2e;
}
.dnd4e-block hr {
border: none;
border-top: 1px solid #b3a079;
margin: 0.7em 0;
}
.dnd4e-block h4, .dnd4e-block h3, .dnd4e-block h2 {
margin: 0.7em 0 0.2em 0;
font-size: 1.1em;
color: #4e5c2e;
text-transform: uppercase;
letter-spacing: 0.03em;
font-family: var(--font-primary);
}
.dnd4e-block .monster-action {
background: #cdcbb5;
padding: 0.2em 0.5em;
border-radius: 3px;
font-weight: bold;
margin: 0.5em 0 0.2em 0;
display: inline-block;
}
/* Power usage backgrounds */
.dnd4e-block .use-atwill { background: var(--background-atwill); color: var(--color-text-light-primary); }
.dnd4e-block .use-encounter { background: var(--background-encounter); color: var(--color-text-light-primary); }
.dnd4e-block .use-daily { background: var(--background-daily); color: var(--color-text-light-primary); }
.dnd4e-block .use-recharge { background: var(--background-recharge); color: var(--color-text-light-primary); }
.dnd4e-block .use-other { background: var(--background-other); color: var(--color-text-light-primary); }
.dnd4e-block .use-item { background: var(--background-item); color: var(--color-text-light-primary); }
.dnd4e-block .use-npc { background: var(--background-npc); color: var(--color-text-light-primary); }
/* List styling for 4e blocks */
.dnd4e-block ul, .dnd4e-block ol {
margin: 0.4em 0 0.4em 1.8em;
padding: 0.1em 0.3em 0.1em 1.8em;
background: var(--gradient-4e);
border-radius: 3px;
list-style: none;
position: relative;
}
.dnd4e-block ul li::before {
display: block;
margin-left: -1em;
margin-right: 0.4em;
font-size: 1em;
content: '\2726';
position: absolute;
color: #b3a079;
}
.dnd4e-block ul li, .dnd4e-block ol li {
margin-bottom: 0.5em;
padding-left: 1.2em;
}
/* Support for .power-block, .monster-block, .item-block, etc. */
.dnd4e-block.power-block { /* extra power-specific tweaks if needed */ }
.dnd4e-block.monster-block { /* extra monster-specific tweaks if needed */ }
.dnd4e-block.item-block { /* extra item-specific tweaks if needed */ }
/* Optional: support for .ritual-block, .hazard-block, etc. */
.dnd4e-block.ritual-block { /* ... */ }
.dnd4e-block.hazard-block { /* ... */ }
/* Responsive tweaks */
@media (max-width: 600px) {
.dnd4e-block {
padding: 0.7em 0.3em;
max-width: 98vw;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment