html - 如何相对链接到 HTML 中的子文件夹?
问题描述
在/foo
我想链接到的页面上/foo/bar
。<a href="./foo/bar">
有效,但它要求我知道我目前在/foo
.
有没有一种方法可以让我在不需要知道当前路径的情况下附加一个后缀?
解决方案
在“html”“head”中,您可以定义基本路径,所有其他 href 都可以相对于该基本路径。“base”标签的一些例子:
<base href="https://www.example.com/">
<base target="_blank">
<base target="_top" href="https://example.com/">
推荐阅读
- join - 当我使用 aj 函数连接两个表时出现错误
- javascript - 我正在为我的项目进行分页。如何通过下拉选项中的用户选择获取每页的记录数?
- r - 右 | 根据其他数据框中的条件更新数据框中的列
- mongoose - 在 Mongoose 中连接文档,其中一个文档具有不同的模式
- .net - 表单提交剃须刀页面上的 400 错误(但仅在 2 分钟后)
- javascript - 两个脚本拒绝一起运行
- sml - 有没有办法在 if - else 语句中将两个动作作为 then 的结果?
- c - 不兼容的指针类型 Eclipse 函数
- c# - 这个符号在c#中是什么意思(^=)
- sql - 有没有办法在 SQL 中加入两个查询,每个查询都有一个 order by?