本地背景图像css不会覆盖样式表css

时间:2017-07-02 18:36:55

标签: html css background

我有一个通用样式表,它引用了一个通用的背景图像。我现在想为我网站上的几个页面制作不同的背景图片。

我尝试在类标记中添加本地样式,!important覆盖样式表。虽然这会阻止原始背景图像显示,但它不会显示新图像。

目前的代码是:

<div class="main_wrapper" style="float: left; background: 
     url("/images/live_body_bg.jpg") no-repeat fixed top right !important; 
     width:100%;">

样式表代码如下:

.main_wrapper {
    padding: 0px 0 30px 0;
    margin: 0px;
    float: left;
    width: 100%;
    background: url(images/body_bg.jpg) no-repeat fixed top right #000;
    background-size: cover;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    border-bottom: 3px #fec500 solid;
}

请告知......

2 个答案:

答案 0 :(得分:0)

您网址中的双引号过早终止了样式信息。您可以使用单引号作为背景网址,而不是双引号。

<div class="main_wrapper" style="float: left; background: 
 url('/images/live_body_bg.jpg') no-repeat fixed top right !important; 
 width:100%;">

答案 1 :(得分:0)

解决了它。文件路径错误。当我将整个网址放在单引号中时,背景图片会正确显示。

相关问题