【问题标题】:CSS background image works for regular page, but not for SharePoint 2013CSS 背景图像适用于常规页面,但不适用于 SharePoint 2013
【发布时间】:2014-01-18 04:34:55
【问题描述】:

我可以在我的自定义 HTML 网页的 CSS 文件中使用以下内容添加整页背景图片,该图片可以拉伸以适应且不会重复:

body { 
    background: url(../dt_images/bg.jpg) no-repeat center center fixed; 
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

我尝试在 SP 2013 网站中执行此操作,但 BG 图像闪烁一秒钟,然后似乎被母版页空白白色背景颜色覆盖...

body {  
    background: url(http://khsp.cloudapp.net/SiteAssets/bg.jpg)  no-repeat center center fixed;  
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

为了覆盖 SP2013 的白色主体背景,我添加了 !important,它现在只渲染白色背景:

background: url(http://khsp.cloudapp.net/SiteAssets/bg.jpg)  no-repeat center center fixed !important;

我尝试将重要内容移到前面,现在它适合整个页面,但是是平铺/重复的:

background: url(http://khsp.cloudapp.net/SiteAssets/bg.jpg)  !important; no-repeat center center fixed;

如何在不重复/平铺的情况下使其适合 SP 2013 中的整个背景?我不介意它是否被拉伸。

谢谢

【问题讨论】:

    标签: css sharepoint


    【解决方案1】:

    尝试像这样分离每个样式

    background-image:url('paper.gif') !important;
    background-repeat:no-repeat !important;
    ..
    ..
    

    【讨论】:

    • 解释为什么这样做。具有描述性。指出 OP 缺少什么和/或出错,然后提出修复/解决方案。
    • 是的用户,您能解释一下为什么需要将它们分开吗?
    • 你有 "!important; no-repeat" 因此不应用 no-repeat。因此,将每个项目分开可以让您更好地控制,并且可以直观地看到正在发生的事情。另外,如果你
    【解决方案2】:

    为了它的价值,这个:

    background: url(http://khsp.cloudapp.net/SiteAssets/bg.jpg)  !important; no-repeat center center fixed;
    

    不好,因为 ;在 !important 之后(CSS 将在该点停止,这就是它重复的原因)。

    【讨论】:

      猜你喜欢
      • 2013-05-18
      • 2019-12-13
      • 1970-01-01
      • 2023-04-04
      • 1970-01-01
      • 1970-01-01
      • 2013-01-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多