Hexo文章卡片美化

Hexo文章卡片美化

🚦采用自定义css方式实现,无需更改主题文件

创建css文件

[Blogroot/source/css/新建 custom.css文件

将以下代码写入刚创建的文件中

悬停卡片效果

#recent-posts>.recent-post-item:not(a):hover {
  box-shadow: 0 5px 15px rgba(0,0,0,.4);
  transform: scale(1.05);
}

卡片擦亮效果

#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);
}

卡片最新文章样式

@media screen and (min-width: 1280px) {
    #recent-posts>.recent-post-item .recent-post-info .newPost {
        position:absolute!important;
        top: 0!important;
        color: #fff!important;
        padding: 0 18px;
        background-color: var(--anzhiyu-main);
        border-radius: 0 0 12px 12px;
        right: -8px;
        margin-top: 0
    }
}

#recent-posts>.recent-post-item:hover .recent-post-info .newPost {
    animation: shake .5s infinite
}

@keyframes shake {
    0% {
        transform: translateX(0)
    }

    25% {
        transform: translateX(-5px)
    }

    50% {
        transform: translateX(5px)
    }

    75% {
        transform: translateX(-5px)
    }

    100% {
        transform: translateX(0)
    }
}

引用css文件

在主题配置文件 _config.anzhiyu.yml中引用

inject: 
   head:
     - <link rel="stylesheet" href="/css/custom.css?1">

执行hexo cl && hexo g && hexo s 查看效果

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容