确定 HTML 文本的字体和大小

发布于 2024-08-04 00:18:40 字数 198 浏览 1 评论 0原文

我需要确定每个 HTML 元素将使用什么字体和大小。它们可以在各种 css、div、span 或元素本身上设置。

如果我要手动执行此操作,我会首先查看元素并向后工作,直到找到具有字体和/或大小的 span、div 或 css。这就是我想要的价值。浏览器显然可以做到这一点,因为它使用字体和大小显示文本。我想打印一个包含两列的列表,一列包含文本,另一列包含字体/大小。

I need to determine what font and size will be used for each HTML element. They may be set in various css, div, span, or on the element itself.

If I were to do this manually I would start by looking at the element and work backwards until I came to span, div, or css that had a font and/or size. That is the value I want. The browser can obviously do this because it displays the text using a font and size. I want to print a list with two columns, one with the text and the other with the font/size.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦过后 2024-08-11 00:18:40

If you are looking for a non-programmatic way: I would suggest the firebug plugin for mozilla. Firebug will not only show you all attributes, but allow you to turn them on and off in the client.

じее 2024-08-11 00:18:40

您想要重现将 HTML 解析为 DOM 对象、将 CSS 解析为这些对象的规则以及在对象之间应用这些规则以最终得到关联的compatedStyle 值的功能吗?对我来说,这听起来很像一个网络浏览器。

您可以尝试编写 Firefox 或 IE WebBrowser 控件的脚本。还有一个正在开发的 开源原生 Java 浏览器/工具包,尽管我不知道实用性如何那是还没有。

You want to reproduce the functionality of parsing HTML into DOM objects, parsing CSS into rules over those objects, and applying those rules across the objects to end up with the associated computedStyle values? That sounds pretty much like a web browser to me.

You could try scripting Firefox or an IE WebBrowser control. There's also an open-source native Java browser/toolkit being developed, though I don't know how practical that is yet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文