如何将重复的平铺图像插入WordPress页面或帖子(不是页面背景)的背景中?

时间:2013-03-30 04:20:06

标签: css wordpress background-image

我再次使用Pytheas theme 摆弄。这一次,我试图在我的页面和帖子的背景上插入一个2色的gif(适合平铺)。请注意,我表示整个页面的背景。那就是,应该保持黑色。有问题的网站/样本帖子是here

我已尽可能广泛地调查我的编码缺陷。目前,我一直在编辑 styles.css 文件。我替换了默认代码:

/* Body & Main
================================================== */
body { background: #eee url("images/main-bg.png") repeat; nowhitespace: afterproperty; font: 12px/1.8 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #444; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body a { color: #f15a23 } /*main link color*/
body a:hover { text-decoration: none; color: #000 }

使用此修订的代码,我将我对CSS的朦胧理解拼凑在一起。

body {
  background: url("http://longgame.org/wp-content/uploads/grid-paper-2color-start.gif")  repeat; nowhitespace: afterproperty;
  background-repeat: repeat;
  background-color:rgba(255,255,255,0.0);
  font: 12px/1.8 'Helvetica Neue', Helvetica, Arial, sans-serif; color: #444; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; 
}

我的想法是我需要 rgba 位以确保颜色是透明的(如果纹理是'后面'它)。我不知道。我在扔飞镖。也许它在错误的地方。也许它只是错了。 :)

我求助于更多合格的人来帮助我。提前感谢您提供的任何指导。

2 个答案:

答案 0 :(得分:1)

不是设置body元素的CSS,而是尝试在#main-content上设置

此外,您只需要第一行即可达到您想要的效果:

#main-content {
    background: url("http://longgame.org/wp-content/uploads/grid-paper-2color-start.gif")  repeat;
}

答案 1 :(得分:0)

如果您不希望影响整个页面的背景,只影响WordPress页面/帖子的背景,则不应该正确调整CSS中body元素的背景,这会影响整个HTML页面,而不是您要应用背景的元素,可能是#main-content

尝试在CSS文件的第24行附近#main-content设置背景属性,例如

#main-content {
    background: url("http://longgame.org/wp-content/uploads/grid-paper-2color-start.gif")  repeat;
}