【问题标题】:Header background not loading标题背景未加载
【发布时间】:2017-09-21 07:00:28
【问题描述】:

我的背景没有加载。它嵌入在通过样式表加载的标题标签中。请参阅下面的 css:

header{
margin: 0;
background-image: url(/images/sagage_header900.png) no-repeat ;
display: block;    
}

提前谢谢!

【问题讨论】:

  • url路径是否正确?你检查了吗?

标签: html css


【解决方案1】:

不要在background-image 属性中使用no-repeat

试试这个:

background: url(/images/sagage_header900.png) no-repeat;

background-image: url(/images/sagage_header900.png);
background-repeat: no-repeat;

【讨论】:

    【解决方案2】:

    尝试删除 no-repeat

    background-image: url(/images/sagage_header900.png);
    

    如果你想添加后台重复:

    background-repeat: no-repeat
    

    如果仍然不起作用,请尝试将!important 添加到背景图像,如下所示:

    background-image: url(/images/sagage_header900.png)!important;
    

    【讨论】:

    • 不要使用重要的......如果他想覆盖现有规则,只需定义更多您的选择器
    • @CyrilBeeckman 我同意你的看法。添加更多选择器而不是添加 !important 是个好主意。
    猜你喜欢
    • 2014-02-17
    • 2020-04-27
    • 2023-01-26
    • 1970-01-01
    • 2018-09-09
    • 1970-01-01
    • 2018-02-04
    • 1970-01-01
    相关资源
    最近更新 更多