简体   繁体   English

图片未加载/显示

[英]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. 我正在使用MVC模型,并且在视图文件夹中有我的CSS工作表。 on which i put a code for the body element like this 我在上面放了一个body元素的代码,像这样

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

MVC structure is like this MVC的结构是这样的

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. 我怎么能在CSS上获取代码..它绝对支持我在锚定HTML页面时获取图像。 but it's not be fetching by stylesheet. 但是它不是通过样式表获取的。 please also specify the reason behind it as well. 请同时说明背后的原因。

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. 您的样式表文件为view/css因此您需要返回../两次以访问图像文件夹。

you can use this as 您可以将其用作

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM