html 框架 css

发布于 2024-09-17 06:51:20 字数 65 浏览 2 评论 0原文

我想知道是否有某种方法可以指定框架中的页面使用以下样式表 家长?或者为框架指定样式表?框架集或框架标签上的一些选项?

I wonder if there's some way to specify that a page in a frame is to use the style sheet of
the parent? Or to specify a style sheet for the frame? Some option on the frameset or frame tag?

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

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

发布评论

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

评论(3

若水微香 2024-09-24 06:51:20

没有这样的选择。但是,您可以在加载后并且从同一域加载时将 link 元素注入到框架中。

There is no such option. But you could inject link element into the frame after it loads and if it loads from the same domain.

反差帅 2024-09-24 06:51:20

我认为没有任何方法可以指导框架使用父级中使用的CSS。大多数人使用框架来实现 css 隔离。

您可以编写一个简单的脚本来将所有外部 css 引用从父级复制到框架

var links = window.parent.document.getElementsByTagName('link');
for( var i=0;i<links.length;i++)
    if(links[i].getAttribute('rel').toLowerCase() == 'stylesheet')
       document.appendChild(links[i]);   

I dont think there is any way by which you can direct a frame to use css used in the parent. Most people use frames to acheive css isolation.

you can write a simple script to copy all external css references from the parent to the frame

var links = window.parent.document.getElementsByTagName('link');
for( var i=0;i<links.length;i++)
    if(links[i].getAttribute('rel').toLowerCase() == 'stylesheet')
       document.appendChild(links[i]);   
寂寞陪衬 2024-09-24 06:51:20

如果框架是 PHP 页面,您可以将它们放置在框架中,例如

<frame src="page.php?style=cool">

然后在框架源中具有

<?php echo '<link rel="stylesheet" href="' . $_GET['style'] . '">'; ?>

的选项不太可能存在,因为每个框架都是它自己的页面、上下文等。

If the frames are PHP pages you could place them in the frame like

<frame src="page.php?style=cool">

Then in the frame source have

<?php echo '<link rel="stylesheet" href="' . $_GET['style'] . '">'; ?>

It is unlikely than an option for <frame> exists since each frame is it's own page, context, etc.

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