Skip to content

Commit aaf902c

Browse files
NetdocsCopilot
andcommitted
Add elevation shadow to code blocks
Give fenced code blocks a soft drop shadow (scheme-aware via --nd-code-shadow; stronger on the dark palette where the page background is close to the block background) so they read as elevated panels and "pop" off the page. Inner children of wrapped blocks reset the shadow to avoid it bleeding inside the panel. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8b71eb0 commit aaf902c

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/Netdocs.Theme.Material/assets/netdocs.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,24 @@ body {
159159

160160
/* Give fenced code blocks a background that reads as a distinct panel against the page
161161
(Material's default is only a few percent lighter, so blocks blend into the page on
162-
the dark scheme). A hairline border reinforces the separation in both schemes. */
162+
the dark scheme). A hairline border plus a soft drop shadow lift the block off the
163+
page so it "pops" as an elevated panel in both schemes. */
164+
:root {
165+
/* Elevation shadow for code panels — tuned per scheme below. */
166+
--nd-code-shadow: 0 0.1rem 0.4rem rgba(0, 0, 0, 0.12), 0 0.05rem 0.1rem rgba(0, 0, 0, 0.08);
167+
}
163168
[data-md-color-scheme="slate"] {
164169
--md-code-bg-color: hsla(var(--md-hue), 15%, 22%, 1);
170+
/* Darker, larger shadow so the panel clearly lifts off the dark page. */
171+
--nd-code-shadow: 0 0.25rem 0.85rem rgba(0, 0, 0, 0.55), 0 0.1rem 0.25rem rgba(0, 0, 0, 0.4);
165172
}
166173

167174
.md-typeset .highlight,
168175
.md-typeset .highlighttable {
169176
border: 0.05rem solid var(--md-default-fg-color--lightest);
170177
border-radius: 0.2rem;
171178
overflow: hidden;
179+
box-shadow: var(--nd-code-shadow);
172180
}
173181

174182
/* Bare <pre><code> blocks (not wrapped in a .highlight container) still need a
@@ -177,13 +185,17 @@ body {
177185
.md-typeset pre > code {
178186
border: 0.05rem solid var(--md-default-fg-color--lightest);
179187
border-radius: 0.2rem;
188+
box-shadow: var(--nd-code-shadow);
180189
}
181190

191+
/* Inner children of a wrapped block share the container's border/shadow, so
192+
reset theirs to avoid a doubled outline or a shadow bleeding inside the panel. */
182193
.md-typeset .highlight pre > code,
183194
.md-typeset .highlighttable pre > code,
184195
.md-typeset .highlighttable .highlight {
185196
border: none;
186197
border-radius: 0;
198+
box-shadow: none;
187199
}
188200

189201
/* Blog post sidebar (`.nd-post-sidebar`) rendered in the left column on post pages: a

0 commit comments

Comments
 (0)