Skip to content

Commit 32b8bfb

Browse files
committed
fix: Handle large # of tabs via scroll
1 parent ed12068 commit 32b8bfb

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

assets/css/v2/style.css

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -864,16 +864,28 @@ blockquote p:last-child {
864864
}
865865

866866
/* Tabs */
867-
.nav-tabs {
868-
list-style: none;
869-
display: flex;
870-
justify-content: start;
871-
border-bottom: 1px solid black;
867+
868+
.tabs-container {
872869
position: relative;
870+
border-bottom: 1px solid black;
871+
white-space: nowrap;
873872

874873
/* Lines extend 1rem into gutter on both sides */
875874
width: calc(100% + 2rem);
876875
margin-left: -1rem;
876+
}
877+
878+
.nav-tabs {
879+
overflow-x: scroll;
880+
overflow-y: hidden;
881+
height: calc(100% + 1px);
882+
scrollbar-width: none;
883+
884+
list-style: none;
885+
display: flex;
886+
justify-content: start;
887+
margin: 0 1rem;
888+
padding: 0;
877889

878890
> :not(:last-child) {
879891
border-right: none;
@@ -910,7 +922,7 @@ blockquote p:last-child {
910922
position: absolute;
911923
display: block;
912924
border-bottom: 1px solid white;
913-
bottom: -1px; /* Moves the line down 1px (aka the thickness of the border) */
925+
bottom: 0;
914926
left: 0;
915927
width: 100%;
916928
z-index: 9999;

layouts/shortcodes/tabs.html

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
{{- $tab_set_id := .Get "name" | default (printf "tabset-%s-%d" (.Page.RelPermalink) (.Page.Scratch.Get "tabset-counter") ) | anchorize -}}
33
{{- $tabs := .Scratch.Get "tabs" -}}
44
{{- if .Inner -}}{{- /* We don't use the inner content, but Hugo will complain if we don't reference it. */ -}}{{- end -}}
5-
<ul class="nav nav-tabs" id="{{ $tab_set_id }}" role="tablist">
6-
{{- range $i, $e := $tabs -}}
7-
{{- $id := printf "%s-%d" $tab_set_id $i -}}
8-
{{- if (eq $i 0) -}}
9-
<li class="nav-item"><a data-toggle="tab" class="nav-link active" href="#{{ $id }}" role="tab" aria-controls="{{ $id }}" aria-selected="true">{{- trim .name " " -}}</a></li>
10-
{{ else }}
11-
<li class="nav-item"><a data-toggle="tab" class="nav-link" href="#{{ $id }}" role="tab" aria-controls="{{ $id }}">{{- trim .name " " -}}</a></li>
12-
{{- end -}}
13-
{{- end -}}
14-
</ul>
5+
<div class="tabs-container">
6+
<ul class="nav nav-tabs" id="{{ $tab_set_id }}" role="tablist">
7+
{{- range $i, $e := $tabs -}}
8+
{{- $id := printf "%s-%d" $tab_set_id $i -}}
9+
{{- if (eq $i 0) -}}
10+
<li class="nav-item"><a data-toggle="tab" class="nav-link active" href="#{{ $id }}" role="tab" aria-controls="{{ $id }}" aria-selected="true">{{- trim .name " " -}}</a></li>
11+
{{ else }}
12+
<li class="nav-item"><a data-toggle="tab" class="nav-link" href="#{{ $id }}" role="tab" aria-controls="{{ $id }}">{{- trim .name " " -}}</a></li>
13+
{{- end -}}
14+
{{- end -}}
15+
</ul>
16+
</div>
1517
<div class="tab-content" id="{{ $tab_set_id }}">
1618
{{- range $i, $e := $tabs -}}
1719
{{- $id := printf "%s-%d" $tab_set_id $i -}}

0 commit comments

Comments
 (0)