# 背景图全屏
# 修改 Stylus
进入 themes\shoka\source\css\_common\outline\header\ 目录
在 brand.styl 文件的 #brand 内将 height 修改为 80vh
在 header.styl 文件的 #header 内将 height 修改为 100vh
在 image.styl 文件的 #imgs 内将 height 修改为 100vh
在 tool.styl 文件的 #tool 内将 top 修改为 90vh
在 waves.styl 文件的 #waves 内
将 margin-bottom 修改为 bottom: 0
增添一行 z-index: 4
position: relative 修改为 position: absolute
# 修改 nunjucks
进入 themes\shoka\layout\_partials\ 目录
在 layout.njk 文件 61 行的 </header>
标签移动到 75 行 </div>
和 <main>
之间
# 图片网格效果
进入 themes\shoka\source\css\_common\outline\header\ 目录
修改 header.styl 文件的 #header 标签内容
#header {
&::before{
background: url(https://cdn.jsdelivr.net/gh/lavender816/CDN@1.8/img/dot.jpg);
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: -4;
background-attachment: fixed;
}
margin: 0 auto;
position: relative;
width: 100%;
height: 100vh;
text-shadow: 0rem .2rem .3rem alpha(#000, .5);
color: var(--header-text-color);
a:hover {
color: currentColor;
}
}
# 首页文章摘要
进入 themes\shoka\source\css\_common\components\pages\home.styl
将内容修改如下
$item {
position: relative;
color: inherit;
width: calc(50% - 2rem);
min-width: calc(50% - 2rem);
height: 14rem;
margin: 1rem;
opacity: 0;
&.show {
@extend .slide-up-big-in;
opacity: 1;
}
+mobile() {
width: calc(100% - 1rem) !important;
min-width: calc(100% - 1rem) !important;
margin: 1rem .5rem !important;
}
}
.index.wrap {
.btn {
position: absolute;
bottom: 0;
right: 0;
padding: .3rem 1rem;
border-radius: 1rem 0;
color: var(--grey-0);
background-image: linear-gradient(to right, var(--color-pink) 0, var(--color-orange) 100%);
&::before {
position: absolute;
display: block;
content: '';
height: calc(100% - 1rem);
width: calc(100% - 1rem);
border-radius: 5rem;
left: .5rem;
top: .8rem;
box-shadow: 0 0 .6rem .6rem var(--color-pink-a3);
background-color: var(--color-pink-a3);
z-index: -1;
}
&:hover {
transform: translateZ(2.5rem);
}
&:hover::before {
transform: translateZ(-2.5rem);
}
}
.meta {
font-size: $font-size-smaller;
color: var(--grey-5);
.ic {
margin-right: .0625rem;
}
.item + .item {
margin-left: .625rem;
}
&.footer {
position: absolute;
bottom: .5rem;
max-width: calc(100% - 7rem);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
justify-content: flex-start;
span {
margin-right: .5rem;
}
}
}
}
.cards {
display: flex;
margin: 0 auto;
align-items: center;
flex-wrap: wrap;
justify-content: space-between;
&.hide .item {
display: none;
}
.item {
@extend $item;
perspective: 62.5rem;
&.show {
display: block !important;
}
.cover,
.info {
position: absolute;
the-flex();
border-radius: .375rem;
height: 100%;
width: 100%;
backface-visibility: hidden;
transform-style: preserve-3d;
transition: ease-in-out 600ms;
}
.cover {
background-position: center;
background-size: cover;
padding: .5rem 1rem;
font-size: $font-size-medium;
color: var(--header-text-color);
overflow: hidden;
transform: rotateY(0deg);
background-image: unquote(hexo-config('index.cover'));
.title {
margin: 0rem;
white-space: normal;
text-align: center;
}
&::before {
position: absolute;
display: block;
content: '';
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: linear-gradient(135deg, #434343 0%, black 100%);
opacity: .25;
z-index: $zindex-0;
}
span {
font-size: $font-size-smallest;
position: absolute;
right: .9375rem;
top: .625rem;
padding: 0 .3125rem;
border-radius: .3125rem;
box-shadow: 0 0rem .3125rem .0625rem rgba(0,0,0,.6);
background: rgba(0,0,0,.5);
}
}
.info {
background-color: var(--grey-0);
transform: rotateY(-180deg);
padding: 1rem 1.5rem 4rem;
justify-content: space-between;
+mobile() {
padding: 1rem 1rem 4rem;
}
.ribbon {
left: -2.5rem;
margin-bottom: .8rem;
max-width: calc(100% + 2rem);
+mobile() {
left: -2rem;
}
}
}
&:nth-child(even) .info {
transform: rotateY(180deg);
}
&.active {
.cover {
transform: rotateY(180deg);
}
.info {
transform: rotateY(0deg);
box-shadow: 0 0 2rem var(--box-bg-shadow);
}
}
&:nth-child(even).active {
.cover {
transform: rotateY(-180deg);
}
}
.title {
.ic {
font-size: 80%;
}
}
ul.posts {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-content: baseline;
min-height: 5rem;
overflow: hidden;
li {
width: 45%;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
color: var(--primary-color);
}
}
}
}
.segments {
the-flex();
> .item {
@extend $item;
display: flex;
border-radius: .625rem;
width: calc(100% - 2rem);
min-width: calc(100% - 2rem);
shadow-box(false);
the-transition();
+mobile() {
flex-direction: column;
height: fit-content;
max-height: fit-content;
}
&:hover {
box-shadow: 0 0 2rem var(--box-bg-shadow);
.cover {
filter: brightness(.3);
}
.cover img {
transform: scale(1.25) rotate(2deg);
}
.info {
width: 75%;
+mobile(){
width: 100%;
}
}
.info h3{
margin: .625rem 0;
color: var(--color-blue);
}
.excerpt {
opacity: 1;
}
}
}
.cover {
width: 50%;
margin-right: 1.5rem;
clip-path: polygon(0 0, 92% 0%, 100% 100%, 0% 100%);
border-radius: .625rem 0 0 .625rem;
overflow: hidden;
the-transition();
+mobile() {
width: 100%;
height: 14rem;
margin: auto;
clip-path: polygon(0 0, 100% 0, 100% 92%, 0 100%);
border-radius: .625rem .625rem 0 0;
}
img {
object-fit: cover;
width: 100%;
height: 100%;
}
}
.info {
position: relative;
width: 50%;
padding: 1rem 1.5rem 3rem 0;
perspective: 62.5rem;
the-transition();
+mobile() {
width: 100%;
height: 14rem;
padding: 0rem 1rem 3rem;
}
.meta {
display: flex;
justify-content: flex-end;
margin: 0;
+mobile() {
.item:not(:first-child) {
display: none;
}
}
}
h3 {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
margin: 3.525rem 0 0 0;
color: var(--primary-color);
the-transition-margin();
}
.excerpt {
overflow: hidden;
font-size: $font-size-small;
max-height: 5rem;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
text-overflow: ellipsis;
opacity: 0;
pointer-events: none;
the-transition();
}
}
> .item:nth-child(even) {
flex-direction: row-reverse;
+mobile() {
flex-direction: column;
}
.cover {
margin-right: auto;
margin-left: 1.5rem;
clip-path: polygon(0 0%, 100% 0%, 100% 100%, 8% 100%);
border-radius: 0rem .625rem .625rem 0;
+mobile() {
width: 100%;
margin: auto;
clip-path: polygon(0 0,100% 0,100% 100%,0 92%);
border-radius: .625rem .625rem 0 0;
}
}
.info {
padding: 1rem 0 3rem 1.5rem;
+mobile() {
padding: 0rem 1rem 3rem;
}
.meta {
justify-content: flex-start;
}
}
.btn {
left: 0;
right: auto;
border-radius: 0 1rem;
background-image: linear-gradient(to right, var(--color-orange) 0, var(--color-pink) 100%);
}
.meta.footer {
right: .5rem;
justify-content: flex-start;
}
&:hover {
.cover img {
transform: scale(1.25) rotate(-2deg);
}
}
}
}
进入 themes\shoka\source\css\_mixins.styl 中增加如下函数
the-transition-margin(duration = .3s, function = ease, delay = 0s, property = margin) {
transition:property duration function delay;
}
# 背景图随鼠标滚动发生位移
找到 themes\shoka\source\js\_app\global.js
20 行左右新增
var imgMover = $('#imgs');
188 行左右新增
var oVal = Math.round(Math.min(300 * window.pageYOffset / contentVisibilityHeight, 100)) / -5; | |
var max = 200 + window.pageYOffset; | |
if (oVal > max) { | |
oVal = max; | |
} | |
imgMover.style.transform = 'translate3d(0,' + oVal + 'vh,0)'; | |
imgMover.style.webkitTransform = 'translate3d(0,' + oVal + 'vh,0)'; | |
imgMover.style.msTransform = 'translate3d(0,' + oVal + 'vh,0)'; | |
imgMover.style.OTransform = 'translate3d(0,' + oVal + 'vh,0)'; |
在 themes\shoka\source\js_app\pjax.js 文件大概 53 行新增
imgMover = $('#imgs')
# 修改标签页显示
要下班了,下次上班再弄
# 实现下拉小箭头
进入 themes/shoka/source/js/_app 目录
在 global.js 17 行新增
var angleBtn=$('#angle');
在 pjax.js 20 行新增
if(!angleBtn) { | |
angleBtn = siteHeader.createChild('div', { | |
id: 'angle', | |
innerHTML: '<span><i class="ic i-angle-down" aria-hidden="true"></i></span>' | |
}); | |
} | |
angleBtn.addEventListener('click',headertopdown); |
在 sidebar.js 220 行新增
const headertopdown = function () { | |
pageScroll($('#main')); | |
} |
在 themes->shoka->source->css->_common->outline->header->header.styl 中最后 (@import... 之前) 新增
/* 首页下拉箭头 */
#angle {
position: absolute;
bottom: 10vh;
left: 50%;
cursor: pointer;
z-index: 5;
transform: translateX(-50%);
}
@media (max-width: 860px) {
#angle {
bottom: 8vh;
}
}
#angle i {
font-size: 35px;
color: #fff;
@extend .up-down;
}