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 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?
  • ¥20 软件开发方法学习来了