Vinay
Vinay

Reputation: 334

Images Not Loading/Displaying

I am facing a critical issue during my project. I am working on MVC model and in the view folder my css sheet is present. on which i put a code for the body element like this

body{
    margin-left:250px;
    background-image:url("/image/background.jpg");  
}

MVC structure is like this

MVC---
    -
    - View
      - css
        -stylesheet.css
    - Controller
    - Model
    -image
    index.php

how could i able to fetch the code on css .. it's absolutely supporting me to fetch images on my html pages when i anchoring them. but it's not be fetching by stylesheet. please also specify the reason behind it as well.

Upvotes: 1

Views: 238

Answers (1)

Harish Singh
Harish Singh

Reputation: 3329

body{
    margin-left:250px;
    background-image:url("../../image/background.jpg");  
}

your style-sheet file is view/css so you need to get back with ../ two times to access image folder.

you can use this as

@base-url: "../../image"; /* path to image/ you can use http url also */
background-image: url("@{base-url}/background.jpg");

Upvotes: 2

Related Questions