前言
niRvana 主题是真的好看啊!功能多,编辑器专门设计,轻拟物设计又区别于现在清一色的扁平风。个性又好看。可是 niRvana 有点贵,我买不起。别的东西抄不了,它的文章排版样式还是可以抄抄的。
于是,320印象舍弃了之前自己H2,H3的样式,采用 niRvana 的样式设计。
下面就让我们开始吧~
之前的样式可以参考这篇文章:
【Vieu常见问题】320印象博客(wordpress)文章页的排版CSS,图片居中,字间距、行间距、段间距调整,标题排版优化
修改前 | 修改后 |
niRvana 的 h2 标题还有悬浮hover特效噢~

CSS 代码
/*[H3]调整*/
.article-content h2:before, .article-content h3:before{
content: "";
display: block;
}
.article-content h3{
position: relative;
font-size: 18px;
height: 40px;
background: #f7fffc;
left: 0;
width: 100%;
border-left: 2px solid #0da872;
-webkit-box-shadow: 1px 0 #fff inset;
box-shadow: 1px 0 #fff inset;
font-weight: bolder;
font-size: 18px;
margin-bottom: 3px;
padding-left: 15px;
text-shadow: 0 1px #fff;
line-height: 2.2;
}
/*[H2]调整*/
.article-content h2{
display: block;
box-shadow: none;
font-size: 20px;
background: none;
border-left: none;
overflow: hidden;
padding: 0;
border-radius:0px;
border-bottom: 1px solid #e7e7e7;
position: relative;
margin-top: 30px;
margin-bottom: 15px;
padding-bottom: 10px;
-webkit-transition: .25s;
transition: .25s;
}
.article-content h2:before {
width: 30px;
height: 3px;
background: -webkit-gradient(linear,left top,left bottom,color-stop(30%,#0da872),color-stop(70%,#0da87273));
background: -webkit-linear-gradient(#0da872 30%,#0da87273 70%);
background: linear-gradient(#0da872 30%,#0da87273 70%);
bottom: -1px;
left: 0;
z-index: 1;
border-radius: 3px;
-webkit-box-shadow: 0 3px 3px rgba(32,160,255,.4);
box-shadow: 0 3px 3px rgba(32,160,255,.4);
-webkit-transition: .25s;
transition: .25s;
display: block;
content: "";
position: absolute;
}
.article-content h2:hover:before{
width: 50px;
}
将上述代码,复制粘贴到主题后台的 自定义代码>自定义CSS样式
就好啦~
如果你不是和博主一样的主题,其实也没有关系啦,一般都是通用的。如果不可行,可以评论区留言反馈噢~
代码解析
这部分CSS 主要还是用到了:before
单独的<h2>标签不能直接加入其他线条的样式,如果通过div嵌套h2,那这样在写文章的时候就比较麻烦了,还要单独为div写样式。
于是,我们可以通过 :before
或者:after
来增加内容。内容 content为空,即content: "";
然后,再加入其他的线条啊,hover动画啊之类的。
:before 定义和用法
:before 选择器在被选元素的内容前面插入内容。
好了,这次教程就到这里啦
影视剪辑 | AE | Pr | 电脑技术 | 摄影摄像 | 电影 | 电视剧 | 二次元
我们下次见
本文首发于320印象,欢迎转载,但是必须保留本文的署名320印象(包含链接)。如您有任何商业合作或者授权方面的协商,请给我留言:admin@mail.320nle.com作者:静海流沙, 转载或复制请以 超链接形式 并注明出处 320印象。
原文地址:《仿 niRvana 轻拟物WordPress主题的二级标题H2和三级标题H3》 发布于2019-10-07
评论 抢沙发