Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Linking a CSS background-image

Edrol97

Bronze Coder
Hi All,

I want to link a css background image to a page. Does anyone know if there is a way to do this?

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
 
Last edited:
Not really sure I understand but, if you want the whole page covered, you can use the body tag.
Not tested but, something like that.
CSS:
body {
    background-image: url(path/to/image);
    background-repeat:no-repeat;
    background-size: cover;
}
 
Not really sure I understand but, if you want the whole page covered, you can use the body tag.
Not tested but, something like that.
CSS:
body {
    background-image: url(path/to/image);
    background-repeat:no-repeat;
    background-size: cover;
}

@Edrol97 Be aware that this will absolutely work, however if you have a short page the background image will only be behind the area taken up by the content as the body is only as tall as your content. You can specify a 100% (or 100vh) height/min-height on body element to ensure it fills the viewport and your background image will then also fill the viewport.
 
@Edrol97 Be aware that this will absolutely work, however if you have a short page the background image will only be behind the area taken up by the content as the body is only as tall as your content. You can specify a 100% (or 100vh) height/min-height on body element to ensure it fills the viewport and your background image will then also fill the viewport.
I've managed to do it here
 
Hey There !
You can easily set a background image for your page using CSS. Just add a background-image property to your CSS, Iam including an example code so you can have an better understanding
Code:
body {
  background-image: url('path-to-your-image.jpg');
  background-size: cover;
  background-repeat: no-repeat; 
  background-position: center; 
}
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom