How to override background image defined in CSS wi

2020-06-30 04:34发布

I have a 'Core.css' which defines a page background image, along with the theme, for the site. But for a specific page I want to change just the background. Any suggestions on how this can be achieved in a separate CSS file?

The HTML for the page is:

<head>
    <link rel="stylesheet" type="text/css" href="core.css" />
    <link rel="stylesheet" type="text/css" href="index.css" />

And core.css defines:

body
{
        background-image: url('bg.png');
}

While index.css defines:

body
{
    background-image:('homeBg.png');
}

Thanks!

7条回答
该账号已被封号
2楼-- · 2020-06-30 05:17

If the page background is set in the body, you can simply overrule it by giving the body in that specific page a class or an id and add (can also be in the same css file...):

body.someClass {
  background: ...
}

or

body#someID {
  background: ...
}

(in both the body part is not really needed as the class and the id overrule the selector)

查看更多
登录 后发表回答