These root-based links can be a bit tricky in wordpress... but I will try to explain:
vc has the base directory of WP:
wp-content
wp-includes
wp-admin
*vários arquivos
now look at the url of each wordpress page of your site:
home = www.meusite.com.br/
página1 = www.meusite.com.br/pagina1/
sub página = www.meusite.com.br/página1/subpágina/
if you rely on the home of your website... one option is:
in the base directory of wordpress, create a folder img
, put the picture there.
Ai in the home or page CSS 1 vc adds:
#bg {
background-image: url('./img/imagem-de-fundo.png');
}
However, from other pages, such as the sub-page, you need to:
#bg {
background-image: url('../img/imagem-de-fundo.png');
}
repair the ../
, which means "in the parent directory of which I am", while ./
says "in the directory where I am".
a tip to streamline and put it all in one CSS file:
see the id of every page that is not a sub-page:
home = 1, page 1 = 2, page A = 3.....
and add that:
#bg {
background-image: url('../img/imagem-de-fundo.png');
}
body.page-id-1 #bg, body.page-id-2 #bg, body.page-id-3 #bg {
background-image: url('./img/imagem-de-fundo.png');
}
for each base page id, you add a body.page-id-x #bg
, so he will find the right path to the images :)
of course q is a kind of gambiarra, another way perhaps would be with some plugin smarter.
But if your site is based on half a dozen main pages and up to a ton of sub-pages, you shouldn’t have any problems following this method.
EDIT:
some properties that can help you setup your background image:
http://www.w3schools.com/css/css_background.asp
background-image: url('/Assets/images/bg/Orange.png') ! Important; test...
– MagicHat
already tried with ! Mportant tb and unsuccessfully :/
– Furabio
puts the style directly in the html tag, if it works the path is right and has some style overlapping if it does not work the path is wrong.... ex: <div id="bg" style="background:url('/Assets/images/bg/Orange.png')no-repeat center; -Webkit-background-size: cover; -Moz-background-size: cover; -o-background-size: cover; background-size: cover;"></div>
– MagicHat
the path to image is correct?
– Caio Felipe Pereira
Friend, take a look at the Netwrok tab of the dev browser console to see the upload order of the css files.
– Lucas Fontes Gaspareto
Hello! Can you send a link with the code or copy the code here? So make it easier to help. Thank you!
– user55929