1
0
Fork 0

Refine and fix CSS

This commit is contained in:
nanxiaobei 2019-08-23 03:50:12 +08:00
parent be85b778d1
commit 08e6f1daef

View file

@ -3,7 +3,7 @@
* A simple, clean, flexible Hugo theme * A simple, clean, flexible Hugo theme
* https://github.com/nanxiaobei/hugo-paper * https://github.com/nanxiaobei/hugo-paper
* Designed by MR.LEE (https://mrlee.me/) * Designed by MR.LEE (https://mrlee.me/)
* Updated in 2019.8.21 * Updated in 2019.8.23
*/ */
/* Variables /* Variables
@ -22,8 +22,8 @@
--secondary: rgba(0, 0, 0, 0.56); --secondary: rgba(0, 0, 0, 0.56);
--tertiary: rgba(0, 0, 0, 0.16); --tertiary: rgba(0, 0, 0, 0.16);
--hljs: #1c1d21; --hljs-bg: #1c1d21;
--code: #f5f5f5; --code-bg: #f5f5f5;
--border: #eee; --border: #eee;
} }
/* Reset /* Reset
@ -43,6 +43,7 @@ body {
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
font-size: 18px; font-size: 18px;
line-height: 1.8; line-height: 1.8;
word-break: break-word;
} }
article, article,
aside, aside,
@ -86,6 +87,7 @@ figure {
margin: 0; margin: 0;
} }
table { table {
width: 100%;
border-collapse: collapse; border-collapse: collapse;
border-spacing: 0; border-spacing: 0;
} }
@ -136,10 +138,6 @@ img {
margin-left: var(--gap); margin-left: var(--gap);
margin-right: var(--gap); margin-right: var(--gap);
} }
.nav .logo:only-child {
margin-left: 50%;
transform: translateX(-50%);
}
.logo a { .logo a {
font-size: 24px; font-size: 24px;
font-weight: 700; font-weight: 700;
@ -147,6 +145,7 @@ img {
.menu { .menu {
display: flex; display: flex;
list-style: none; list-style: none;
word-break: keep-all;
overflow-x: auto; overflow-x: auto;
} }
.menu li + li { .menu li + li {
@ -181,7 +180,6 @@ img {
} }
.page-header { .page-header {
margin-bottom: 24px; margin-bottom: 24px;
overflow: hidden;
} }
.page-header h1 { .page-header h1 {
font-size: 40px; font-size: 40px;
@ -214,13 +212,17 @@ img {
justify-content: center; justify-content: center;
height: 320px; height: 320px;
margin-bottom: var(--header-height); margin-bottom: var(--header-height);
}
.first-entry .entry-header {
overflow: hidden; overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
} }
.first-entry .entry-header h2 { .first-entry .entry-header h2 {
font-size: 40px; font-size: 40px;
} }
.first-entry .entry-content { .first-entry .entry-content {
max-height: 75px;
margin-top: 14px; margin-top: 14px;
margin-bottom: 14px; margin-bottom: 14px;
font-size: 16px; font-size: 16px;
@ -235,25 +237,21 @@ img {
padding: var(--gap); padding: var(--gap);
background: #fff; background: #fff;
border-radius: var(--radius); border-radius: var(--radius);
overflow: hidden; transition: transform 0.1s;
transition: box-shadow 0.2s;
} }
.post-entry:active { .post-entry:active {
transform: scale(0.96); transform: scale(0.96);
transition: 0.1s;
} }
.entry-header h2 { .entry-header h2 {
font-size: 24px; font-size: 24px;
} }
.entry-content { .entry-content {
max-height: 44px;
margin-top: 8px; margin-top: 8px;
margin-bottom: 8px; margin-bottom: 8px;
color: var(--secondary); color: var(--secondary);
font-size: 14px; font-size: 14px;
line-height: 1.6; line-height: 1.6;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
@ -366,40 +364,58 @@ img {
margin-top: 10px; margin-top: 10px;
} }
.post-content table { .post-content table {
width: 100%;
margin-bottom: 32px; margin-bottom: 32px;
border-collapse: collapse;
border-spacing: 0;
} }
.post-content th, .post-content table th,
.post-content td { .post-content table:not(.highlighttable) td {
min-width: 80px; min-width: 80px;
padding: 12px 8px; padding: 12px 8px;
line-height: 1.5; line-height: 1.5;
word-break: break-word;
border-bottom: 1px solid var(--border); border-bottom: 1px solid var(--border);
} }
.post-content th { .post-content table th {
font-size: 14px; font-size: 14px;
text-align: left; text-align: left;
} }
.post-content td code:only-child { .post-content table:not(.highlighttable) td code:only-child {
margin-left: 0; margin-left: 0;
margin-right: 0; margin-right: 0;
} }
.post-content pre, .post-content .highlight,
.post-content .highlight { .post-content pre {
margin: 0 calc(var(--gap) * -1) 32px; margin-left: calc(var(--gap) * -1);
background: var(--hljs) !important; margin-right: calc(var(--gap) * -1);
margin-bottom: 32px;
background: var(--hljs-bg) !important;
border-radius: var(--radius); border-radius: var(--radius);
} }
.post-content pre code { .post-content .highlight pre {
margin-left: 0; margin-left: 0;
margin-right: 0; margin-right: 0;
padding: var(--gap); margin-bottom: 0;
white-space: inherit;
background: transparent;
} }
/* table */
.post-content .highlighttable {
table-layout: fixed;
}
.post-content .highlighttable td:first-child {
width: 40px;
}
.post-content .highlighttable td .linenodiv {
padding-right: 0 !important;
}
.post-content .highlighttable td .linenodiv pre,
.post-content .highlighttable td .highlight {
margin-bottom: 0;
}
.post-content .highlighttable td .highlight pre code::-webkit-scrollbar {
display: none;
}
/* inline */
.post-content .highlight span {
background: transparent !important;
}
.post-content code { .post-content code {
margin-left: 4px; margin-left: 4px;
margin-right: 4px; margin-right: 4px;
@ -407,41 +423,18 @@ img {
font-family: Menlo, Monaco, "Courier New", Courier, monospace; font-family: Menlo, Monaco, "Courier New", Courier, monospace;
font-size: 0.78em; font-size: 0.78em;
line-height: 1.5; line-height: 1.5;
white-space: pre-wrap; background: var(--code-bg);
background: var(--code);
border-radius: 2px; border-radius: 2px;
} }
.post-content pre code {
.post-content .highlight table, display: block;
.post-content .highlight pre {
margin-bottom: 0;
}
.post-content .highlight table {
width: auto;
}
.post-content .highlight pre {
margin-left: 0; margin-left: 0;
margin-right: 0; margin-right: 0;
padding: var(--gap);
color: rgba(255, 255, 255, 0.8);
background: transparent;
border-radius: 0;
} }
.post-content .highlight table td {
min-width: auto;
padding: 0;
border-bottom: 0;
}
.post-content .highlight table td:first-child pre code {
padding-right: 16px;
color: var(--tertiary);
text-align: right;
}
.post-content .highlight table td:last-child pre code {
padding-left: 0;
overflow: hidden;
}
.post-content .highlight .ln {
margin-right: 16px;
color: var(--tertiary);
}
.post-content blockquote { .post-content blockquote {
margin: 0 0 0 calc(var(--gap) * -1); margin: 0 0 0 calc(var(--gap) * -1);
padding: 0 0 0 21px; padding: 0 0 0 21px;
@ -474,7 +467,7 @@ img {
color: var(--secondary); color: var(--secondary);
font-size: 14px; font-size: 14px;
line-height: 34px; line-height: 34px;
background: var(--code); background: var(--code-bg);
border-radius: 2px; border-radius: 2px;
} }
.post-tags a:hover { .post-tags a:hover {