From 6e90e520d60dc7dad28f6e3976c4c386746bad1a Mon Sep 17 00:00:00 2001 From: Shane Nelson Date: Sun, 17 Dec 2017 22:53:25 -0500 Subject: [PATCH] Avoid resizing page/content on sidebar toggle --- src/theme/book.css | 28 +++++++++++++--------------- src/theme/stylus/general.styl | 1 + src/theme/stylus/page.styl | 22 ++++++++++------------ src/theme/stylus/variables.styl | 3 ++- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/theme/book.css b/src/theme/book.css index 4699400d..6417c67b 100644 --- a/src/theme/book.css +++ b/src/theme/book.css @@ -6,6 +6,7 @@ body { body { margin: 0; font-size: 1rem; + overflow-x: hidden; } code { font-family: "Source Code Pro", Consolas, "Ubuntu Mono", Menlo, "DejaVu Sans Mono", monospace, monospace; @@ -109,28 +110,25 @@ table thead td { white-space: nowrap; } .page-wrapper { - padding-left: 300px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; min-height: 100%; - -webkit-transition: padding-left 0.5s, margin-right 0.5s; - -moz-transition: padding-left 0.5s, margin-right 0.5s; - -o-transition: padding-left 0.5s, margin-right 0.5s; - -ms-transition: padding-left 0.5s, margin-right 0.5s; - transition: padding-left 0.5s, margin-right 0.5s; -} -@media only screen and (max-width: 1060px) { - .page-wrapper { - padding-left: 0; - } -} -.sidebar-hidden .page-wrapper { - padding-left: 0; + width: 100%; + -webkit-transition: padding-left 0.5s, margin-left 0.5s; + -moz-transition: padding-left 0.5s, margin-left 0.5s; + -o-transition: padding-left 0.5s, margin-left 0.5s; + -ms-transition: padding-left 0.5s, margin-left 0.5s; + transition: padding-left 0.5s, margin-left 0.5s; } .sidebar-visible .page-wrapper { padding-left: 300px; - margin-right: -300px; +} +@media only screen and (max-width: 1079px) { + .sidebar-visible .page-wrapper { + padding-left: 0; + margin-left: 300px; + } } .page { outline: 0; diff --git a/src/theme/stylus/general.styl b/src/theme/stylus/general.styl index 9a5cc974..9d2ff94c 100644 --- a/src/theme/stylus/general.styl +++ b/src/theme/stylus/general.styl @@ -6,6 +6,7 @@ html, body { body { margin: 0; font-size: 1rem; + overflow-x: hidden } code { diff --git a/src/theme/stylus/page.styl b/src/theme/stylus/page.styl index 447444a5..8ba72245 100644 --- a/src/theme/stylus/page.styl +++ b/src/theme/stylus/page.styl @@ -1,26 +1,24 @@ @require 'variables' .page-wrapper { - padding-left: $sidebar-width box-sizing: border-box min-height: 100% + width: 100% // Animation: slide away - transition: padding-left 0.5s, margin-right 0.5s - - @media only screen and (max-width: $max-page-width-with-hidden-sidebar) { - padding-left: 0 - } -} - -.sidebar-hidden .page-wrapper { - padding-left: 0 + transition: padding-left 0.5s, margin-left 0.5s } .sidebar-visible .page-wrapper { padding-left: $sidebar-width - margin-right: - $sidebar-width +} + +@media only screen and (max-width: $page-plus-sidebar-width - 1) { + .sidebar-visible .page-wrapper { + padding-left: 0 + margin-left: $sidebar-width + } } .page { @@ -30,7 +28,7 @@ .content { margin-left: auto - margin-right:auto + margin-right: auto max-width: $content-max-width padding-bottom: 50px diff --git a/src/theme/stylus/variables.styl b/src/theme/stylus/variables.styl index db1609bd..c02af07b 100644 --- a/src/theme/stylus/variables.styl +++ b/src/theme/stylus/variables.styl @@ -1,4 +1,5 @@ $sidebar-width = 300px $page-padding = 15px -$max-page-width-with-hidden-sidebar = 1060px $content-max-width = 750px +$max-page-width-with-hidden-sidebar = 1060px +$page-plus-sidebar-width = $content-max-width + $sidebar-width + $page-padding * 2