Skip to content

Commit

Permalink
Fix Nextra margin-top in nested lists (#2686)
Browse files Browse the repository at this point in the history
Before:

<img width="846" alt="image"
src="https://github.com/WATonomous/infra-config/assets/5977478/965bf0bb-d26b-40fa-a9ac-4a959b78b4f8">


After:

<img width="845" alt="image"
src="https://github.com/WATonomous/infra-config/assets/5977478/d7dcc120-e891-4a2a-aa6d-28a70a705717">


The problem is that by default, Nextra applies `first:nx-mt-0` on
`:first-child`. But in some cases (as shown above), the nested list is
not the first child. In the example above, the first child is the `a`
tag:

<img width="1413" alt="image"
src="https://github.com/WATonomous/infra-config/assets/5977478/e3e326b2-f8c1-47bb-8678-808b61262b03">

The fix is to use `:first-of-type` instead.

Related: shuding/nextra#863
  • Loading branch information
ben-z authored Apr 22, 2024
1 parent 243c722 commit fb34e7a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,10 @@ select:focus,
textarea {
font-size: 16px;
}


/* Fix margin issue for nested lists: https://github.com/shuding/nextra/issues/863#issuecomment-2068517369 */
li > ul.first\:nx-mt-0:first-of-type,
li > ol.first\:nx-mt-0:first-of-type {
margin-top: 0;
}

0 comments on commit fb34e7a

Please sign in to comment.