From fb3ba0953f5b03bb52a71582216867df924d2007 Mon Sep 17 00:00:00 2001 From: Josh Kriese Date: Tue, 6 Sep 2022 10:29:13 -0400 Subject: [PATCH 1/2] Adding sticky header functionality for mobile sizes --- inst/resources/bs4_book/bs4_book.css | 48 +++++++++++++++++++++++++++- inst/templates/bs4_book.html | 4 +-- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/inst/resources/bs4_book/bs4_book.css b/inst/resources/bs4_book/bs4_book.css index 0bc45a0b1..c79a0bdd3 100644 --- a/inst/resources/bs4_book/bs4_book.css +++ b/inst/resources/bs4_book/bs4_book.css @@ -58,7 +58,53 @@ main {margin-top: 1rem;} padding-left: 1rem; } .sidebar-book { - margin-top: 1rem; + background-color: #fff; + padding-top: 1rem; + position: relative; + transition: .5s ease top; + top: -4rem; + transform: translateY(4rem); + z-index: 1 + } + .sidebar-book .nav-toggle-btn { + height: 2.5rem; + /*! margin-left: 1rem; */ + } + .sidebar-chapter #toc { + margin-top: 0; + transition: .5s ease margin-top; + } + + .scrolled-to-toc .book-title { + width: calc(100% - 3rem); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + margin-bottom: 0; + } + + .scrolled-to-toc .book-title a { + line-height: 2.5rem; + } + + .scrolled-to-toc .book-title a::before { + display: none; + } + + .scrolled-to-toc .sidebar-book { + background-color: #fff; + box-shadow: 0 3px 8px rgba(0,0,0,0.3); + left: 0; + padding-bottom: .5rem; + padding-top: .5rem; + position: sticky; + top: 0; + transform: none; + z-index: 1 + } + + .scrolled-to-toc .sidebar-chapter #toc { + margin-top: 4rem; } } @media (min-width: 992px) { diff --git a/inst/templates/bs4_book.html b/inst/templates/bs4_book.html index 68578084c..b95fe0878 100644 --- a/inst/templates/bs4_book.html +++ b/inst/templates/bs4_book.html @@ -83,11 +83,11 @@ Skip to main content
-

+

$title$$if(subtitle)$: $subtitle$$endif$

- +