dreljie602951 2019-01-28 17:40
浏览 78
已采纳

如果在html页面中的图像没有显示但如果在同一个html页面包含在另一个html页面中它的工作时如何修复它?

I am creating a web application which has a separate file for header specifications called head.php. I have included this file in rest of my web pages. Now, when I open head.php in browser, it doesn't display any of the images mentioned in it. Whereas, when I open rest of the pages that include head.php in browser, the images mentioned in head.php are displayed properly. How should I fix it ??

I have tried copying images in the same folder. But I don't think that there is any issue in the url part, or else images wouldn't be shown at all in any webpage. Her's the code of head.php :

    <!doctype html>
    <html>
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style type="text/css">
        #foot{
            height:50px;
            width:100%;
            margin-top:140px;
            position:relative;
            bottom:0;
            left:0;
            background-image:url("img/w4.jpg");
        }
        p{
            color:white;
            float:right;
            padding-right:20px;
            font-size:18px;
        }
    </style>
    </head>
    <footer>
    <div id="foot">
        <p>Leave Management Portal</p>
    </div>
    </footer>
    </html>
  • 写回答

1条回答 默认 最新

  • dongyoucha0645 2019-01-28 18:07
    关注

    img/w4.jpg is a relative path. It is saying "inside the images folder inside the current folder, there is a w4.jpg image."

    If you change locations say from mysite.com/ to mysite.com/otherpage your relative path will be looking for /otherpage/img/w4.jpg.

    You can add a slash at the beginning to say "start at the root" /img/w4.jpg or you can use a PHP method to always point to the same directory no matter where you are in your website directory structure.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)