CSS 选择器片段支持 [英] CSS selector fragment support

查看:30
本文介绍了CSS 选择器片段支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

片段(或哈希)被广泛用于指定文档中的某些特定片段.

Fragments (or hashes) in URL are widely used to specify some specific fragment in a document.

例如下面的片段

http://example.com/page.pnp#<fragment>

通常引用类似<div id="<fragment>"/> 在 HTML 文档中.

Usually references something like <div id="<fragment>" /> or <a name="<fragment>" /> in a HTML document.

一个支持 CSS 选择器作为片段的标准,如下所示:

http://example.com/page.pnp#css(<CSS selector>)

是否有任何应用程序在使用它?浏览器支持它会很好吗?例如,浏览器可以只显示页面的选定片段或突出显示选定的片段.或者为开发人员提供一个选项,以使用 CSS 或 JS 突出显示所选片段.有人可以将其作为功能请求提交给相关的浏览器开发人员吗?

Are there any applications using it? Would it be nice for browser to support it? For example, browser could display only the selected fragments of the page or highlight the selected fragments. Or provide an option for developers to highlight the selected fragments with CSS or JS. Can somebody submit it to the relevant browser devs as a feature request?

还有哪些其他方式可以引用 HTML 页面中的特定内容?例如,如果我想对 HTML 页面中的某个特定元素发表评论,还有什么其他方法可以指定文档中的该位置,最好使用 URI 或其他一些方便的标识符?

What are other ways to reference specific content in a HTML page? For example, if I want to comment on some specific element in a HTML page, what are any other ways to specify that position in the document, preferably by using URI, or some other convenient identifier?

推荐答案

您链接到的文档并不是真正的标准;它甚至在副标题中写着非官方草案",在它写着状态的地方:

The document you link to isn't really a standard; it even says "Unofficial Draft" in the subtitle, and under where it says Status:

本文档只是潜在规范的公开工作草案.它没有任何形式的官方地位,也不代表任何标准组织的支持或共识.

This document is merely a public working draft of a potential specification. It has no official standing of any kind and does not represent the support or consensus of any standards organisation.

...所以将其称为标准"是完全不合适的.更好的术语是概念"或实验".

... so it is completely inappropriate to refer to it as a "standard". A better term for this would be "concept" or "experiment".

话虽如此,基本实现以浏览器扩展的形式存在(或者至少,它们在首次发布时已经存在);您可以在第 8 节中找到这些链接.

That being said, rudimentary implementations exist (or at least, they did at the time it was first published) in the form of browser extensions; you can find links to these in section 8.

AFAIK,不过,自从 发布后的最初几个月之后,根本没有任何相关活动社区小组为此成立,我加入了.要么它从未获得过吸引力,要么就是实施起来不太可行.

AFAIK, though, there hasn't been any activity around this at all after the first few months since the community group for this was formed and I joined. Either it never gained traction or it just wasn't very feasible to implement after all.

现在,一如既往,片段标识符只能指向具有相应 id 属性或命名锚点的元素.在可预见的未来,情况似乎仍将如此.

For now, as always, fragment identifiers can only point to elements with the respective id attribute, or named anchors. It seems it'll remain that way for the foreseeable future.

这篇关于CSS 选择器片段支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆