• 绝对路径和相对路径


    简介:

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

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

    假设 info.html路径是: c:Inetpubwwwrootsiteslablainfo.html
    假设 index.html路径是: c:Inetpubwwwrootsiteslablaindex.html
     info.html加入 index.html 超链接的代码应该这样写:

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

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

    假设 info.html路径是: c:Inetpubwwwrootsiteslablainfo.html
    假设 index.html路径是: c:Inetpubwwwrootsitesindex.html
     info.html加入 index.html 超链接的代码应该这样写:

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

    假设 info.html路径是: c:Inetpubwwwrootsiteslablainfo.html
    假设 index.html路径是: c:Inetpubwwwrootindex.html
     info.html加入 index.html 超链接的代码应该这样写:

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

    假设 info.html路径是: c:Inetpubwwwrootsiteslablainfo.html
    假设 index.html路径是: c:Inetpubwwwrootsiteswowstoryindex.html
     info.html加入 index.html 超链接的代码应该这样写:

    <a href = "../wowstory/index.html">index.html</a>
     
    如何表示下级目录 
    引用下级目录的文件,直接写下级目录文件的路径即可。

    假设 info.html路径是: c:Inetpubwwwrootsiteslablainfo.html
    假设 index.html路径是: c:Inetpubwwwrootsiteslablahtmlindex.html
     info.html加入 index.html 超链接的代码应该这样写:


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

    假设 info.html路径是: c:Inetpubwwwrootsiteslablainfo.html
    假设 index.html路径是: c:Inetpubwwwrootsiteslablahtml utorialsindex.html 
     info.html加入 index.html 超链接的代码应该这样写:

    <a href = "html/tutorials/index.html">index.html</a>
     
    当前文件路径:
    网页路径
     
    引用文件路径:
     
    网页路径:
     
    以下操作中的文件路径都是:
     
    介绍:
    /  :表示根目录
    ../  : 表示上一级目录(../../上二级)
    ./ :表示当前目录
     
    错误的引用方法:
     
    正确的方法:
     
    1.从根目录出发找:
    /snowinmay/templates/js/js_base.js
     
    2.从当前文件往上找。
    ../../templates/js/js_base.js
  • 相关阅读:
    Java基础---多线程
    Java基础---多态、内部类、异常、包
    Java基础---继承、抽象、接口
    Java基础---面向对象
    NSOperation使用
    根据两个日期计算相差的年月日
    代理模式简单说明
    Lua程序设计入门
    zmq-ios framwork
    cocoapods安装与使用
  • 原文地址:https://www.cnblogs.com/snowinmay/p/3217135.html
Copyright © 2020-2023  润新知