cristi
cristi

Reputation: 397

Why does not source local images?

This syntax is incorrect?

CODE CSS:

.navbar-custom{
    background:url(images/bgi/bg.png);
}

CODE HTML

    <nav class="navbar navbar-custom">
       //some code HTML
    </nav>

I put an image to view image made way

enter image description here

Do you know where does this matter?

EDIT:

enter image description here

Upvotes: 1

Views: 50

Answers (2)

Quentin
Quentin

Reputation: 943207

The syntax is correct. The URL is not.

URLs in stylesheets are relative to the stylesheet URL, not the HTML document URL.

The images directory is a sibling to the css directory. It isn't inside it.

background:url(../images/bgi/bg.png);

Upvotes: 4

Luke Twomey
Luke Twomey

Reputation: 1285

Is your css file in the "test" folder? The path you provide in url is relative to wherever the css file is saved.

You also have no quotes around your path, which should be there - but I'm not sure would cause the issue.

Try:

.navbar-custom{
    background: url("/images/bgi/bg.png");
}

With the forward slash, you're going back to the root of the site - and then into the images folder. This would solve the problem if for example you have css in a sub-folder of test. I've also added in the quotes for completeness.

Upvotes: 5

Related Questions