-1

My background image is not working.

CSS:

.main {
    color:rgb(5, 1, 0);
    position:absolute;
    border:3px solid lightgreen
    background-image:url("images/some_image.png");
}

I've looked it over many times and I can't find what's wrong with this code. The URL is right, the syntax is right... What is wrong with this?

1
  • This is a relative URL not an absolute URL. Commented Jun 1, 2015 at 20:17

4 Answers 4

4

There is no semicolon after the border element definition.

Here is the correct definition:

border: 3px solid lightgreen;
background-image: url("images/some_image.png");
Sign up to request clarification or add additional context in comments.

Comments

2
  border:3px solid lightgreen
  background-image:url("images/some_image.png");

You seem to have forgotten a semicolon on the line above.

Also, this is a relative, not absolute URL.

Comments

2

.main {
  width: 100%;
  height: 500px;
  color: rgb(5, 1, 0);
  position: absolute;
  border: 3px solid lightgreen;
  background-image: url("http://www.hdwallpapersimages.com/wp-content/uploads/2014/01/Winter-Tiger-Wild-Cat-Images.jpg");
  -webkit-background-size: cover;
}
<div class="main">
</div>

Comments

0

As of right now, you're including your background-image inside your border! Put a semicolon after your border declaration, and your background image should work fine, if some_image.png is in the correct directory.

Your css should look like this:

.main {
  color:rgb(5, 1, 0);
  position:absolute;
  border:3px solid lightgreen;
  background-image:url("images/some_image.png");

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.