wordpress去除正文content和主页左侧的作者author、时间date、评论comment留下的空白

版权声明:本文为博主原创文章,转载请注明出处并附上链接,谢谢! https://blog.csdn.net/julius_lee/article/details/85213620

      站点shares.club建好后,查看主页时,发现虽然虽然已经去除了正文content和主页左侧的作者author、时间date、评论comment等信息,但是主页还是在对文章进行显示时排版很难看,没有自动覆盖到去除了空白位置,这样的体验非常差,左侧有一个竖直的很长很长的空白。为此,决定一定要改个简洁的方式来展示主页,将标题和正文都对齐显示。由于本人从未学习过PHP相关的知识,所以虽然可能是几句话的事,但是对初次接触的人来说,还是很难,事后事实也如此。曲折经历如下:

     首先在百度上查找了相关方法,得出的结果大多是安装插件,或者插入几段代码,而且写的非常不标准,都是反复转摘的文章,有些原文站点甚至已经关闭了,无从考究,而且时间大多已经是5年前的文章,WordPress版本都不知道更新了多少个!只能算是部分正确,也许是我设置不对,但是如果你看到本文了,相信你也已经尝试了很多方法了!最后还是通过搜索英文关键字,才找到了准确的答案,百度搜录的答案都没什么效果,根据提示去改了些CSS,也没有改正确!

说明:本人使用的WordPress主题是twentysixteen,其它主题应该类似。本次尝试是在已经去除了正文content和主页左侧的作者author、时间date、评论comment的情况下只针对左侧空白做的处理,其它情况下,自己可以试试,可能最多效果不同。

@media screen and (min-width: 61.5625em) {

body:not(.search-results) article:not(.type-page) .entry-content,
body:not(.search-results) article:not(.type-page) .entry-footer {
width:100%;
float:none;
}

body:not(.search-results) article:not(.type-page) .entry-footer {
margin-top:20px;
padding-top:10px;
border-top:1px solid #efefef;
width:100%;

}

body.no-sidebar:not(.search-results) article:not(.type-page) .entry-content {
margin:0;
width: 50.00000001%;
float:none;
width:100%;
}

body.no-sidebar:not(.search-results) article:not(.type-page) .entry-footer {
margin:0;
float:none;
width:100%;
}

.no-sidebar .entry-header,
.no-sidebar .entry-content,
.no-sidebar .entry-summary,
.no-sidebar .entry-footer,
.no-sidebar .comments-area,
.no-sidebar .image-navigation,
.no-sidebar .post-navigation,
.no-sidebar .pagination,
.no-sidebar .page-header,
.no-sidebar .page-content,
.no-sidebar .content-bottom-widgets {
margin-right: 0;
margin-left: 0;
}

}

另外,本段代码是粘贴到了twenty sixteen child 模板下实现的,以避免更新父模板导致代码被替换。

处理后的截图如下:

非常完美!

本文同步发布在:https://ideashare.club/,欢迎访问!

--------------------- 
作者:我在地球村--做个有意思的人 
来源:CSDN 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/julius_lee/article/details/85213620