From 6131f1612cbe9146b46dbfb1dd760aa165e12834 Mon Sep 17 00:00:00 2001 From: Captain ALM Date: Wed, 17 Aug 2022 13:44:18 +0100 Subject: [PATCH] Provide the ability to get the nav item width of text. --- base.css | 13 ++++++++++--- index.go.html | 1 + index.js | 10 ++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/base.css b/base.css index 24d4369..ba5c0dc 100644 --- a/base.css +++ b/base.css @@ -7,6 +7,14 @@ Under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 Internati padding: 0; box-sizing: border-box; } +#st{ + position: absolute; + left: -1080px; + top: -1080px; + font-size: 1em; + visibility: hidden; + white-space: nowrap; +} main{ padding-top: 70px; padding-left: 6px; @@ -122,6 +130,8 @@ main{ } .menu a, .vmenu a{ display: block; +} +.menu a, .vmenu a, #st{ padding: 24px 16px; } .vmenu li{ @@ -321,9 +331,6 @@ main{ float: right; width: auto; } - .vnav{ - display: none; - } .menu li{ float: left; } diff --git a/index.go.html b/index.go.html index deb0ae8..ba943b6 100644 --- a/index.go.html +++ b/index.go.html @@ -195,5 +195,6 @@ License.

+
\ No newline at end of file diff --git a/index.js b/index.js index 6b25dbb..7968b33 100644 --- a/index.js +++ b/index.js @@ -290,4 +290,14 @@ function SortDurationD(a, b) { } else { return 1 } +} +function GetNavTextWidth(s) { + var st = document.getElementById("st"); + if (st) { + st.textContent = s + var trw = st.clientWidth; + st.textContent = "" + return trw; + } + return 8 * s.length + 32 } \ No newline at end of file