之前即可。 ``` #字体自行修改 ``` ### 7、给导航添加抽屉控制按钮和博主信息按钮 在 `handsome/component/headnav.php` 中搜索 `selectNavbarCollapse`, 大约在 30 行 在 `` 下面插入如下代码即可 ```
``` 若需要在导航折叠的时候,将某些元素隐藏掉,可以对相关元素添加 `class="hidden-folded"` ### 8、打赏图标跳动 文章页最底部的打赏图标添加跳动效果,将以下代码添加至后台主题设置 自定义 CSS 即可。 ``` .btn-pay { animation: star 0.5s ease-in-out infinite alternate; } @keyframes star { from { transform: scale(1); } to { transform: scale(1.1); } } ``` ### 9、头像呼吸光环和鼠标悬停旋转放大 鼠标经过头像放大,并且加有呼吸灯效果。请将以下代码添加至后台主题设置自定义 CSS。 ``` .img-full { width: 100px; border-radius: 50%; animation: light 4s ease-in-out infinite; transition: 0.5s; } .img-full:hover { transform: scale(1.15) rotate(720deg); } @keyframes light { 0% { box-shadow: 0 0 4px #f00; } 25% { box-shadow: 0 0 16px #0f0; } 50% { box-shadow: 0 0 4px #00f; } 75% { box-shadow: 0 0 16px #0f0; } 100% { box-shadow: 0 0 4px #f00; } } ``` ### 10、随机彩色标签云 之前看过一个彩色标签云的插件,这里用 js 为标签随机添加上预先定义的颜色,每次刷新都会进行换色: 使用方法:请将下方代码添加到后台主题设置自定义 JavaScript 中。 ```javascript let tags = document.querySelectorAll("#tag_cloud-2 a"); let colorArr = ["#428BCA", "#AEDCAE", "#ECA9A7", "#DA99FF", "#FFB380", "#D9B999"]; tags.forEach(tag => { tagsColor = colorArr[Math.floor(Math.random() * colorArr.length)]; tag.style.backgroundColor = tagsColor; }); ``` ### 11、文章内头图和文章图片悬停放大并将超出范围隐藏 打开后台 - 更改外观 - 设置外观 - 开发者设置 - 复制代码粘贴至自定义 CSS 即可 ```none /*首页文章列表头图悬停放大并将超出范围隐藏*/ .index-post-img { overflow: hidden; } .index-post-img-small .post-feature .index-img-small { overflow: hidden; } .panel-picture .post-thumbnail { overflow: hidden; } .item-thumb { transition: all 0.3s; } .item-thumb-small { transition: all 0.3s; } .panel-picture .post-thumbnail .post-thumbnail-inner { transition: all 0.3s; } .item-thumb:hover { transform: scale(1.1) } .item-thumb-small:hover { transform: scale(1.1) } .panel-picture .post-thumbnail .post-thumbnail-inner:hover { transform: scale(1.1) } ``` ### 12、首页文章列表悬停上浮 打开后台 - 更改外观 - 设置外观 - 开发者设置 - 复制代码粘贴至自定义 CSS 即可 ```none /*首页文章列表悬停上浮*/ .blog-post .panel:not(article) { transition: all 0.3s; } .blog-post .panel:not(article):hover { transform: translateY(-10px); box-shadow: 0 8px 10px rgba(73, 90, 47, 0.47); } .blog-post .panel-small:not(article) { transition: all 0.3s; } .blog-post .panel-small:not(article):hover { transform: translateY(-10px); box-shadow: 0 8px 10px rgba(73, 90, 47, 0.47); } .box-shadow-wrap-normal { transition: all 0.3s; } .box-shadow-wrap-normal:hover { transform: translateY(-10px); box-shadow: 0 8px 10px rgba(73, 90, 47, 0.47); } ``` ### 13、侧边栏添加网站总访客数统计 首先在 Typecho 后台外观选择编辑当前外观 functions.php 中,添加下方代码并保存文件: ```none //总访问量 function theAllViews() { $db = Typecho_Db::get(); $row = $db->fetchAll('SELECT SUM(VIEWS) FROM `typecho_contents`'); echo number_format($row[0]['SUM(VIEWS)']); } ``` 然后在 `handsome/component/sidebar.php` 文件找到合适的位置插入以下调用代码: ```none
``` handsome 主题添加代码位置在:网站根目录 /usr/themes/handsome/component/sidebar.php ### 14、侧边栏添加加载耗时显示 在 Typecho 后台外观选择编辑当前外观 functions.php 中,添加下方代码并保存文件: ```none //加载耗时 function timer_start() { global $timestart; $mtime = explode( ' ', microtime() ); $timestart = $mtime[1] + $mtime[0]; return true; } timer_start(); function timer_stop( $display = 0, $precision = 3 ) { global $timestart, $timeend; $mtime = explode( ' ', microtime() ); $timeend = $mtime[1] + $mtime[0]; $timetotal = number_format( $timeend - $timestart, $precision ); $r = $timetotal < 1 ? $timetotal * 1000 . " ms" : $timetotal . " s"; if ( $display ) { echo $r; } return $r; } ``` 在 sidebar.php 文件找到合适的位置插入以下调用代码: ```none
``` ### 15、自定义字体 [handsome 主题](https://www.moewah.com/tag/typecho-theme-handsome/ "handsome主题")使用至今,个人对默认字体不是非常喜欢觉得软绵绵的,对于段落篇幅较大的文章阅读起来会非常吃力。个人偏爱 `Noto Serif SC` 字体多一些。考虑到不想对 `handsome.min.css` 主题样式文件有过多的修改,所以仅在 `handsome.min.css` 文件引入外部字体,然后在主题设置中进行自定义 CSS。(如果你也想使用这样的字体,请根据教程自行修改。) 1、引入外部字体,修改 `handsome/assets/css` 路径下的 `handsome.min.css` 文件,在第 1 行加入 ```none @import url("https://fonts.loli.net/css?family=Noto+Serif+SC:400,400italic,700,700italic"); ``` 2、主题设置 - 开发者设置 - 自定义 CSS ```none .h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 { font-weight: 600 !important; } h1 , h2 , h3 , h4 , body , p , li{ font-family: "Noto Serif SC","Source Sans Pro","Hiragino Sans GB","Microsoft Yahei",SimSun,Helvetica,Arial,Sans-serif,monospace !important; font-display: swap; } #post-content h1, #post-content h2 { display: inline !important; } #post-content h1, #post-content h2, #post-content h3, #post-content h4, #post-content h5, #post-content h6 { line-height: 2.0 !important; } ```
Loading...
Loading...
/*时光机播放视频*/