Skip to content

Commit ec6438b

Browse files
committed
fix: Handle large # of tabs via scroll
1 parent bb3cdec commit ec6438b

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
@@ -870,17 +870,29 @@ blockquote p:last-child {
870870
}
871871

872872
/* Tabs */
873-
.nav-tabs {
874-
list-style: none;
875-
display: flex;
876-
justify-content: start;
877-
border-bottom: 1px solid black;
873+
874+
.tabs-container {
878875
position: relative;
879876
z-index: -1;
877+
border-bottom: 1px solid black;
878+
white-space: nowrap;
880879

881880
/* Lines extend 1rem into gutter on both sides */
882881
width: calc(100% + 2rem);
883882
margin-left: -1rem;
883+
}
884+
885+
.nav-tabs {
886+
overflow-x: scroll;
887+
overflow-y: hidden;
888+
height: calc(100% + 1px);
889+
scrollbar-width: none;
890+
891+
list-style: none;
892+
display: flex;
893+
justify-content: start;
894+
margin: 0 1rem;
895+
padding: 0;
884896

885897
> :not(:last-child) {
886898
border-right: none;
@@ -917,7 +929,7 @@ blockquote p:last-child {
917929
position: absolute;
918930
display: block;
919931
border-bottom: 1px solid white;
920-
bottom: -1px; /* Moves the line down 1px (aka the thickness of the border) */
932+
bottom: 0;
921933
left: 0;
922934
width: 100%;
923935
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)