我看到很多网站(moz.com、hubspot.com)都使用背景图像作为布局。如何在WordPress上轻松添加单个背景图像?我还想在此处添加布局:http://moz.com/blog 在我的博客上。我该怎么做?
是否为单页添加背景图像/布局?
2 个回复
最合适的回答,由SO网友:iyrin 整理而成
这假设您要为特定页面添加背景图像:
为您想要的背景创建CSS类。
body.custombg {background: url("images/background.gif"); }
在标题中,您可以使用类似这样的内容来检查特定页面。<body <?php if(is_page(123)) echo \'class="custombg"\' ?>>
请参见Conditional Tags 更多关于你能做什么的想法。至于该网站的布局,你应该联系他们,看看他们是在使用公开的主题,还是自定义设计。
SO网友:kaiser
您可以简单地使用body_class()
.
<body <?php body_class( is_page( \'about\' ) ? \'special-class\' : \'\' ); ?>>
结束