简体   繁体   English

如何设置WordPress PHP链接的样式?

[英]How do I style a WordPress PHP link?

<div class="past-page"><?php previous_posts_link( '&laquo; Previous Page' ); ?></div>

Hello! 你好! I'm having a bit of troubles trying to solve the styling of a pagination button. 尝试解决分页按钮的样式时遇到了一些麻烦。 I tried styling the past-page div, but that made a white box show up when no link was there... which was not the result I wanted. 我尝试设置上一页div的样式,但是当没有链接时,这会显示一个白框……这不是我想要的结果。

So, I'm wondering if I can somehow add styling in the php tag here? 所以,我想知道是否可以在此处的php标签中添加样式? The style I want to add is 我要添加的样式是

font-size: 10pt;
text-transform: uppercase;
font-weight: bold;
background: #fff;
padding: 10px;

use :not(:empty) to add style to a div that is 'not empty'; 使用:not(:empty)将样式添加到“非空”的div中; otherwise, when it is blank, it reverts back to the default CSS: 否则,当它为空时,它将恢复为默认CSS:

<style>
.past-page:not(:empty) {
 font-size: 10pt;
 text-transform: uppercase;
 font-weight: bold;
 background: #fff;
 padding: 10px;
}
</style>

Alternatively, you could apply the style always unless empty then make it invisible: 另外,您可以始终应用样式,除非为空,否则使其不可见:

<style>
.past-page {
 font-size: 10pt;
 text-transform: uppercase;
 font-weight: bold;
 background: #fff;
 padding: 10px;
}

.past-page:empty {
 display: none !important;
}
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM