Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert a background image in CSS (Twitter Bootstrap)

Tags:

How can i add a image background to my website?

body {      margin: 0;      background: url(background.png);      background-size: 1440px 800px;      background-repeat:no-repeatdisplay: compact;      font: 13px/18px "Helvetica Neue", Helvetica, Arial, sans-serif; 

I did that much but nothing shows up on my page. I'm a CSS beginner.

Updated:

body {  margin: 0;  background-image: url(.../img/background.jpg);  background-size: 1440px 800px;  background-repeat:no-repeat;  display: compact;  font: 13px/18px "Helvetica Neue", Helvetica, Arial, sans-serif; 
like image 913
AppSensei Avatar asked Jun 08 '12 16:06

AppSensei


People also ask

How do I add a background image to my URL?

Usage is simple — you insert the path to the image you want to include in your page inside the brackets of url() , for example: background-image: url('images/my-image. png');

Can you give a div a background image?

Say you want to put an image or two on a webpage. One way is to use the background-image CSS property. This property applies one or more background images to an element, like a <div> , as the documentation explains.


1 Answers

Put the background url in quotes.

It should be background: url('background.png');

See here for working demo.

You also have an issue with the background-repeat line missing a semicolon in between two statements. If your background is really tiny you won't see it because of that issue.

Just to update on the solution, among the other issues, the background file was being refrenced with .../background.jpg when it should have been ../background.jpg (2 dots, not 3).

like image 91
sachleen Avatar answered Oct 14 '22 14:10

sachleen