Minimal-mistakes: ์Šคํ‹ฐํ‚ค ํ—ค๋”๋ฅผ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•

์— ๋งŒ๋“  2016๋…„ 08์›” 29์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: mmistakes/minimal-mistakes

  • [x] ํ…Œ๋งˆ ์‚ฌ์šฉ์— ๊ด€ํ•œ ์งˆ๋ฌธ์ž…๋‹ˆ๋‹ค.
  • [ ] ๋‚˜๋Š” ์ด๊ฒƒ์ด Jekyll, GitHub Pages ๋˜๋Š” ๋ฒˆ๋“ค ํ”Œ๋Ÿฌ๊ทธ์ธ ์ค‘ ํ•˜๋‚˜๊ฐ€ ์•„๋‹Œ ํ…Œ๋งˆ์˜ ๋ฒ„๊ทธ๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.
  • [x] ์ด๊ฒƒ์€ ๊ธฐ๋Šฅ ์š”์ฒญ์ž…๋‹ˆ๋‹ค.
  • [ ] ๋ชจ๋“  gem์„ bundle update .
  • [ ] bundle exec jekyll build ๋กœ ๋กœ์ปฌ์—์„œ ํ…Œ์ŠคํŠธํ–ˆ์Šต๋‹ˆ๋‹ค.

ํ™˜๊ฒฝ์ •๋ณด

  • ์ตœ์†Œ ์‹ค์ˆ˜ ๋ฒ„์ „: commit 4340aa7835c1398a3aa5e3e073f2dc02810971e4
  • github-pages ๋˜๋Š” jekyll gem ๋ฒ„์ „: jekyll 3.2.1
  • ์šด์˜ ์ฒด์ œ: ์šฐ๋ถ„ํˆฌ 16.04

๊ธฐ๋Šฅ ์š”์ฒญ(์งˆ๋ฌธ?)

์•ˆ๋…•ํ•˜์„ธ์š”, ํ›Œ๋ฅญํ•œ ์ž‘์—…์— ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

๋‚˜๋Š” ํ—ค๋” ์Šคํ‹ฑ์„ ๋งŒ๋“ค๋ ค๊ณ  ์‹œ๋„ํ–ˆ์ง€๋งŒ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค.

_masterhead.scss ๋ฅผ fixed ๋กœ ์—…๋ฐ์ดํŠธํ•œ ๋‹ค์Œ sidebar ๋ฐ main ์ปจํ…Œ์ด๋„ˆ์˜ ์—ฌ๋ฐฑ์„ ๊ฐ€์ง€๊ณ  ํ”Œ๋ ˆ์ดํ–ˆ์ง€๋งŒ ์Šคํฌ๋กค๊ณผ sticky ์‚ฌ์ด๋“œ๋ฐ” js๊ฐ€ ํ—ค๋”๋ฅผ ๊ณ„์† ์—‰๋ง์œผ๋กœ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

์ด๊ฒƒ์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‚˜ ํ…œํ”Œ๋ฆฟ์— ๊ธฐ๋Šฅ์œผ๋กœ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ๋ ค์ฃผ์‹ค ์ˆ˜ ์žˆ๋Š”์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค.

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

๊ฐ์‚ฌ ํ•ด์š”!

์‹ค์ œ๋กœ ๊ท€ํ•˜์˜ ์‚ฌ์ดํŠธ๋ฅผ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ด ๋งŽ์€ ๋„์›€์ด ๋˜์—ˆ์Šต๋‹ˆ๋‹ค! ๋ฐฐ๊ฒฝ๊ณผ ์‚ฌ์ด๋“œ๋ฐ” ํŒจ๋”ฉ์ด ๋ˆ„๋ฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋น ๋ฅธ ์งˆ๋ฌธ, ํŒจ๋”ฉ์„ ๋ณธ๋ฌธ์— ์ ์šฉํ•˜์ง€ ์•Š๊ณ  #main ์ปจํ…Œ์ด๋„ˆ์— ์ ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ์Šคํƒ€์ผ์˜ ์ฐจ์ด๊ฐ€ ์žˆ๋‚˜์š”?

๋ˆ„๊ตฐ๊ฐ€๊ฐ€ ๊ทธ๊ฒƒ์„ ์‚ฌ์šฉํ•˜๊ธฐ๋ฅผ ์›ํ•  ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•œ ์ตœ์ข… diff๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋ฒ ์ด์Šค๋ฅผ ์ˆ˜์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ผ์ธ์ด ์›๋ž˜ ์ปค๋ฐ‹๊ณผ 100% ์œ ์‚ฌํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์ง€๋งŒ ์ฐพ๊ธฐ๊ฐ€ ์–ด๋ ต์ง€ ์•Š์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 .masthead {
-  position: relative;
+  position: fixed;
+  top: 0;
+  width: 100%;
+  height: $masthead-height;
+
   border-bottom: 1px solid $border-color;
   -webkit-animation: intro 0.3s both;
           animation: intro 0.3s both;
@@ -16,6 +20,7 @@
     <strong i="10">@include</strong> clearfix;
     padding: 0.1em 0.1em 0.1em;
     font-family: $sans-serif-narrow;
+    background-color: #fff;

     <strong i="11">@include</strong> breakpoint($x-large) {
       max-width: $x-large;
diff --git a/_sass/_page.scss b/_sass/_page.scss
index e95f07d..487c5c7 100644
--- a/_sass/_page.scss
+++ b/_sass/_page.scss
@@ -6,6 +6,7 @@
   <strong i="12">@include</strong> container;
   <strong i="13">@include</strong> clearfix;
   margin-top: 2em;
+  padding-top: $masthead-height;
   padding-left: 1em;
   padding-right: 1em;
   animation: intro 0.3s both;
diff --git a/_sass/_sidebar.scss b/_sass/_sidebar.scss
index 9df17ea..712498a 100644
--- a/_sass/_sidebar.scss
+++ b/_sass/_sidebar.scss
@@ -8,6 +8,7 @@

 .sidebar {
   <strong i="14">@include</strong> clearfix();
+  padding-top: $masthead-height;
   margin-bottom: 1em;

   <strong i="15">@include</strong> breakpoint($large) {
diff --git a/_sass/_variables.scss b/_sass/_variables.scss
index d14acf0..eec32ee 100644
--- a/_sass/_variables.scss
+++ b/_sass/_variables.scss
@@ -139,3 +139,5 @@ $box-shadow                 : 0 1px 1px rgba(0, 0, 0, 0.125);
 $navicon-width              : 28px;
 $navicon-height             : 4px;
 $global-transition          : all 0.2s ease-in-out;
+
+$masthead-height            : 50px;

๋ชจ๋“  3 ๋Œ“๊ธ€

๋‹ค์Œ์€ ์‹œ์ž‘ํ•˜๊ธฐ ์œ„ํ•œ ๋ช‡ ๊ฐ€์ง€ ํžŒํŠธ์ž…๋‹ˆ๋‹ค.

.masthead {
-   position: relative;    
+   position: fixed;
+   top: 0;
    border-bottom: 1px solid #f2f3f3;
    -webkit-animation: intro 0.3s both;
    animation: intro 0.3s both;
    -webkit-animation-delay: 0.15s;
    animation-delay: 0.15s;
    z-index: 20;
+   width: 100%;
+   background: white;  // set a color to hide content that may appear below masthead
+   height: 85px; // need a magic number here which may break in different viewports
}

๊ทธ๋Ÿฌ๋ฉด ์˜ฌ๋ฐ”๋ฅธ ์œ„์น˜์˜ ๋งˆ์ŠคํŠธํ—ค๋“œ์— ๋ฉ”๋‰ด๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๋ณธ๋ฌธ ๋‚ด์šฉ๊ณผ ๊ฒน์น˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋ ค๋ฉด ๋งˆ์ŠคํŠธํ—ค๋“œ(๋˜๋Š” ๊ทธ ์ด์ƒ)์˜ ๋†’์ด์™€ ์ผ์น˜ํ•˜๋Š” ํŒจ๋”ฉ์„ ์ƒ๋‹จ์— ์ถ”๊ฐ€ํ•˜์—ฌ ์ง€์›Œ์•ผ ํ•ฉ๋‹ˆ๋‹ค.

body {
    margin: 0;
-   padding: 0;
+   padding: 85px 0 0;  // padding-top equal to masthead height or greater
    color: #494e52;
    font-family: -apple-system,".SFNSText-Regular","San Francisco","Roboto","Segoe UI","Helvetica Neue","Lucida Grande",Arial,sans-serif;
    line-height: 1.5;
}

์ด๊ฒƒ์€ ๋‹น์‹ ์ด ํ•„์š”๋กœ ํ•˜๋Š” ๊ฒƒ์— ๋งค์šฐ ๊ฐ€๊น๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค. ์ž‘์„ฑ์ž ์‚ฌ์ด๋“œ๋ฐ”๊ฐ€ sticky ํด๋ฆฌํ•„ ์Šคํฌ๋ฆฝํŠธ๋กœ "๊ณ ์ฐฉ"๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ๋ณต์ œํ•˜๊ณ  ์œ„์น˜๋ฅผ ๊ณ„์‚ฐํ•œ ๋‹ค์Œ ์†์„ฑ์„ ์ง€์›ํ•˜์ง€ ์•Š๋Š” ๋ธŒ๋ผ์šฐ์ €์— ๋Œ€ํ•ด position: sticky ๋ฅผ ๊ฐ€์งœ๋กœ ์žฌ๋ฐฐ์น˜ํ•˜์—ฌ ์ผ๋ถ€ ๋ถ€๋‘๊ต๋ฅผ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

๊ณ ์ • ๋งˆ์ŠคํŠธํ—ค๋“œ์— ๋Œ€ํ•ด ๋‹ค๋ฅธ CSS๋ฅผ ์ œ๊ณฑํ•˜๋ฉด ๊ทธ์— ๋”ฐ๋ผ ์ž‘์„ฑ์ž ์‚ฌ์ด๋“œ๋ฐ”๊ฐ€ ์กฐ์ •๋  ๊ฒƒ์ด๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์€ ๊ฒฝ์šฐ ํ•ด๋‹น ์Šคํฌ๋ฆฝํŠธ๋ฅผ ๊ฐ€์ง€๊ณ  ๋†€์•„์•ผ ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. https://github.com/wilddeer/stickyfill


๋‚ด ๊ฐœ์ธ ์‚ฌ์ดํŠธ ์—๋Š” ๊ณ ์ •๋œ ์œ„์น˜์˜ ๋งˆ์ŠคํŠธํ—ค๋“œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฒ ์ด์Šค๋Š” ์ด ์ฃผ์ œ์— ๋Œ€ํ•ด 1:1์ด ์•„๋‹ˆ์ง€๋งŒ ๋™์ผํ•œ ์Šคํฌ๋ฆฝํŠธ์™€ ํ•ญ๋ชฉ์„ ๋งŽ์ด ๊ณต์œ ํ•ฉ๋‹ˆ๋‹ค. ์œ„์˜ ์ œ์•ˆ ์‚ฌํ•ญ์ด ์ ์šฉ๋˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ์ž‘๋™ํ•˜๋„๋ก ํ•˜๋Š” ๋ช‡ ๊ฐ€์ง€ ์•„์ด๋””์–ด๋ฅผ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ฐ์‚ฌ ํ•ด์š”!

์‹ค์ œ๋กœ ๊ท€ํ•˜์˜ ์‚ฌ์ดํŠธ๋ฅผ ํ™•์ธํ•˜๋Š” ๊ฒƒ์ด ๋งŽ์€ ๋„์›€์ด ๋˜์—ˆ์Šต๋‹ˆ๋‹ค! ๋ฐฐ๊ฒฝ๊ณผ ์‚ฌ์ด๋“œ๋ฐ” ํŒจ๋”ฉ์ด ๋ˆ„๋ฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋น ๋ฅธ ์งˆ๋ฌธ, ํŒจ๋”ฉ์„ ๋ณธ๋ฌธ์— ์ ์šฉํ•˜์ง€ ์•Š๊ณ  #main ์ปจํ…Œ์ด๋„ˆ์— ์ ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ์Šคํƒ€์ผ์˜ ์ฐจ์ด๊ฐ€ ์žˆ๋‚˜์š”?

๋ˆ„๊ตฐ๊ฐ€๊ฐ€ ๊ทธ๊ฒƒ์„ ์‚ฌ์šฉํ•˜๊ธฐ๋ฅผ ์›ํ•  ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•œ ์ตœ์ข… diff๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋ฒ ์ด์Šค๋ฅผ ์ˆ˜์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ผ์ธ์ด ์›๋ž˜ ์ปค๋ฐ‹๊ณผ 100% ์œ ์‚ฌํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์ง€๋งŒ ์ฐพ๊ธฐ๊ฐ€ ์–ด๋ ต์ง€ ์•Š์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 .masthead {
-  position: relative;
+  position: fixed;
+  top: 0;
+  width: 100%;
+  height: $masthead-height;
+
   border-bottom: 1px solid $border-color;
   -webkit-animation: intro 0.3s both;
           animation: intro 0.3s both;
@@ -16,6 +20,7 @@
     <strong i="10">@include</strong> clearfix;
     padding: 0.1em 0.1em 0.1em;
     font-family: $sans-serif-narrow;
+    background-color: #fff;

     <strong i="11">@include</strong> breakpoint($x-large) {
       max-width: $x-large;
diff --git a/_sass/_page.scss b/_sass/_page.scss
index e95f07d..487c5c7 100644
--- a/_sass/_page.scss
+++ b/_sass/_page.scss
@@ -6,6 +6,7 @@
   <strong i="12">@include</strong> container;
   <strong i="13">@include</strong> clearfix;
   margin-top: 2em;
+  padding-top: $masthead-height;
   padding-left: 1em;
   padding-right: 1em;
   animation: intro 0.3s both;
diff --git a/_sass/_sidebar.scss b/_sass/_sidebar.scss
index 9df17ea..712498a 100644
--- a/_sass/_sidebar.scss
+++ b/_sass/_sidebar.scss
@@ -8,6 +8,7 @@

 .sidebar {
   <strong i="14">@include</strong> clearfix();
+  padding-top: $masthead-height;
   margin-bottom: 1em;

   <strong i="15">@include</strong> breakpoint($large) {
diff --git a/_sass/_variables.scss b/_sass/_variables.scss
index d14acf0..eec32ee 100644
--- a/_sass/_variables.scss
+++ b/_sass/_variables.scss
@@ -139,3 +139,5 @@ $box-shadow                 : 0 1px 1px rgba(0, 0, 0, 0.125);
 $navicon-width              : 28px;
 $navicon-height             : 4px;
 $global-transition          : all 0.2s ease-in-out;
+
+$masthead-height            : 50px;

๋‚ด์šฉ๊ณผ ๊ตฌ์„ฑ ๋ฐฉ์‹์— ๋”ฐ๋ผ ๋‹ค๋ฆ…๋‹ˆ๋‹ค. ๋ชจ๋“  ์ฃผ์š” ์ฝ˜ํ…์ธ ๊ฐ€ ๋ฉ”์ธ์— ์žˆ๋‹ค๋ฉด ํŒจ๋”ฉ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๊ทธ๊ฒƒ์„ ์‹œ๋„ํ•˜๊ณ  ๋ฌด์Šจ ์ผ์ด ์ผ์–ด๋‚˜๋Š”์ง€๋ณด์‹ญ์‹œ์˜ค. ์ œ๋Œ€๋กœ ํ•˜๋ ค๋ฉด ์‹œํ–‰์ฐฉ์˜ค๊ฐ€ ํ•„์š”ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ ์–ด๋„ ๋‚˜๋Š” ๋ณดํ†ต ํ•œ๋‹ค :wink:

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰