zoukankan      html  css  js  c++  java
  • HTML有2种路径的写法:绝对路径和相对路径

    HTML有2种路径的写法:绝对路径和相对路径

    版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/l18848956739/article/details/53411241

    HTML相对路径(Relative Path)
    同一个目录的文件引用
    如果源文件和引用文件在同一个目录里,直接写引用文件名即可。

    我们现在建一个源文件info.html,在info.html里要引用index.html文件作为超链接。

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/sites/blabla/index.html
    在info.html加入index.html超链接的代码应该这样写:

    <a href = "index.html">index.html</a>

    如何表示上级目录
    ../表示源文件所在目录的上一级目录,../../表示源文件所在目录的上上级目录,以此类推。

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/sites/index.html
    在info.html加入index.html超链接的代码应该这样写:

    <a href = "../index.html">index.html</a>

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/index.html
    在info.html加入index.html超链接的代码应该这样写:

    <a href = "../../index.html">index.html</a>

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/sites/wowstory/index.html
    在info.html加入index.html超链接的代码应该这样写:

    <a href = "../wowstory/index.html">index.html</a>

     
    如何表示下级目录
    引用下级目录的文件,直接写下级目录文件的路径即可。

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/sites/blabla/html/index.html
    在info.html加入index.html超链接的代码应该这样写:

    <a href = "html/index.html">index.html</a>

    假设info.html路径是:c:/Inetpub/wwwroot/sites/blabla/info.html
    假设index.html路径是:c:/Inetpub/wwwroot/sites/blabla/html/tutorials/index.html

  • 相关阅读:
    mysql添加用户
    ubantu更新源
    内存的crash记录分析
    windows下sublime2 clojure环境配置
    服务器使用recast navigation
    网络库crash以及boost asio strand dispath分析
    CentOS7 监控进程网络流量工具安装
    vs2013提高编译速度
    Centos6.5 gitlab安装使用
    linux命令行将已有项目提交到github
  • 原文地址:https://www.cnblogs.com/bwdblogs/p/11101288.html
Copyright © 2011-2022 走看看