-2
#hero {
    background: url('/wp-content/themes/bootstrap2wordpress/assets/img/hero-bg.jpg') 50% 0 repeat
}

Here is my code but still doesn't work

Kirk Beard
  • 9,569
  • 12
  • 43
  • 47
  • share the site url – Rajkumar Gour Nov 09 '17 at 04:40
  • Could you clarify what you mean by fix? Just a normal background image? or fixed background image (paralax effect)? – AlbertSamuel Nov 09 '17 at 05:13
  • Questions seeking debugging help (**"why isn't this code working?"**) must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it **in the question itself**. See: [mcve] – Rob Nov 09 '17 at 05:16

4 Answers4

0

Without more information (some HTML to go with it) or a webpage you are having trouble with, it is very hard to understand what you are trying to accomplish.

I would try something like this, as it sounds like you are trying to have the background image repeat.

hero {
background: url('/wp-content/themes/bootstrap2wordpress/assets/img/hero-bg.jpg') repeat;
}

https://www.w3schools.com/cssref/css3_pr_background.asp

RLessard
  • 146
  • 6
0

Try this, But you need to add this to your header.php or any PHP file header section. This will not work in CSS file.For more details visit URL

<style>
   .hero {
    background-image: url("<?php echo content_url(); ?>/wp-content/themes/bootstrap2wordpress/assets/img/hero-bg.jpg") 50% 0 repeat;
  }
</style>

Hope this will help you.

Sunil Dora
  • 1,407
  • 1
  • 13
  • 26
0

Just navigate up a directory or two using ../

hero {
  background: url('../../img/hero-bg.jpg') repeat;
}
admcfajn
  • 2,013
  • 3
  • 24
  • 32
0

I am assuming hero is your class name thats why prefixed with .

In your code I could not find . , so check the same one more time.This also can be one issue if it is not there in your code.

Can you try this way:

    .hero {
    background: url('/wp-content/themes/bootstrap2wordpress/assets/img/hero-bg.jpg');
    background-size: 50% 0;
    background-repeat: repeat;
}
All about JS
  • 562
  • 2
  • 10