在打印 CSS 中插入页面标题

发布于 2024-12-29 02:47:51 字数 144 浏览 1 评论 0原文

我需要抓取我网站上的页面标题,然后将其插入到页面的打印版本中。当然,我有一个单独的 print.css,但是有什么方法可以获取该标题数据,也许作为使用 jQuery 的变量,然后使用 CSS 插入它,例如。 div:在{内容:“变量名称位于此处”}之前?或者有更好的方法吗?

I need to grab the page title's on my website and then insert it into the print version of the pages. I have a seperate print.css ofcourse, but is there any way I can grab that title data, maybe as a variable using jQuery, then insert it using CSS, eg. div:before {content:"variable name goes here"} ? Or is there a better approach to this?

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

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

发布评论

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

评论(2

っ左 2025-01-05 02:47:51

我只是在主页上有一个隐藏元素,它在打印 CSS 中获取 display:block;

I'd just have a hidden element on your main page that gets a display:block; in the print CSS.

滿滿的愛 2025-01-05 02:47:51

当然!

// this would be an example of how to grab the title
<script language="JavaScript">
alert(document.title);
</script>

我的方法会略有不同。

<h1 class="web-hide">the page title goes here</h1>

然后,您将拥有一个可见/不可见的 .web-hide,具体取决于页面的打印/不打印版本。

Sure!

// this would be an example of how to grab the title
<script language="JavaScript">
alert(document.title);
</script>

My approach would be slightly different.

<h1 class="web-hide">the page title goes here</h1>

And then you would have a .web-hide that would be visible/not-visible depending on the print/not-print version of the page.

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