第九篇 Hexo 魔改实录 | 为主页文章卡片添加擦亮动画效果

前言

这里主要是参考铭心石刻大佬的博客来完成,具体效果如下展示:

操作步骤

1 新增 css 内容

  • 新建文件 source/css/home.css 文件,新增以下内容:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#recent-posts > .recent-post-item:not(a)::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 200%;
background: linear-gradient(to right, transparent, white, transparent);
transform: translateX(-200%);
transition: transform 0.5s linear;
z-index: 1;
}
#recent-posts > .recent-post-item:not(a):hover::before {
transform: translateX(100%) skewX(-60deg);
}

2 引入内容

  • _config.anzhiyu.yml 主题配置文件下 inject 配置项中 head 处;
  • 引入 home.css 文件:
1
2
3
inject:
head:
- <link rel="stylesheet" href="/css/home.css"> # 首页文章卡片擦亮效果

3 重启服务

  • 重启 hexo 服务:
1
hexo clean && hexo g && hexo s