【问题标题】:background disappearing after adding background-image:no-repeat;添加背景图像后背景消失:无重复;
【发布时间】:2017-04-28 13:14:14
【问题描述】:

我正在尝试为我的 wordpress 网站设置背景图片。

.content:before {
content: "";
background-image: url("gfx/SevenWonders.jpg");
/*background: #fff;*/
background-size:600px 700px;
background-repeat: no-repeat;
position: absolute;
z-index: -9999;
top: 0;
right: 28.5%;
bottom: 0;
left: -10000px;
}

这是我的带有背景图像的 CSS 代码。我调整了大小,因为图像

对我的网站来说相当大。和!添加 background-repeat: no-repeat 后,

背景不可显示。我只看到白色背景。

当然,我用谷歌搜索找到解决方案,但几乎所有人都在说

关于语法错误,但我在我的代码中找不到任何语法错误..

【问题讨论】:

  • 你能提供一下你的 HTML 和 CSS 吗?
  • @ajinkyanarkar hmmm.. 我不确定.. 因为我正在使用 wordpress,我正在使用 php 和 style.css 文件.. css 文件真的很大.. 它有3000+行..
  • 你能提供一个链接吗?
  • @AhmedGinani 抱歉,我不知道任何允许上传代码并与他人共享代码的网站。 GitHub?未注册。我解决了我的问题。我刚刚找到合适的尺寸。对不起

标签: css wordpress background-repeat


【解决方案1】:

检查this 小提琴。问题在于您在 css 中的 left 属性值。

.content:before {
content: "";
background-image: url("https://placeholdit.imgix.net/~text?txtsize=33&txt=350%C3%97150&w=350&h=150");
/*background: #fff;*/
background-size:600px 700px;
background-repeat: no-repeat;
position: absolute;
z-index: -9999;
top: 0;
right: 28.5%;
bottom: 0;
left: 0px;
}

【讨论】:

    猜你喜欢
    • 2015-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-29
    • 2019-02-28
    • 1970-01-01
    • 2020-05-09
    • 2012-03-03
    相关资源
    最近更新 更多