1

我是一个搞乱代码的初学者......我正在尝试自定义博客评论表单。我用 chrome 跟踪元素,我发现一个 iframe src到一个只有博主评论表单的 html 文件。从评论表单源 html 中,我找到了一个外部 css 链接,其中包含我需要自定义的所有 css。

但是我在模板中发现了空的src。如果我像上面提到的那样编辑主机并编辑 HTML 文件,(带有编辑的 css 链接)我可以自定义 iframe css 吗?还是被博主限制(使用令牌?)?

或者,有没有办法用 javascript/jquery 覆盖 css?

(不能发布到源的链接,链接很大,stackoverflow 不会让我)

4

3 回答 3

1

您无法访问 iframe 的样式。您必须将此视为页面中的另一个浏览器窗口。你页面上的css不会影响它,你不能用javascript访问它。这就是 iframe 的缺点...

于 2012-08-03T18:27:41.770 回答
0

如果我理解,这是可能的。编辑:但不能跨域工作。可能出于安全原因。

首先,您应该阅读此链接 http://benvinegar.github.com/seamless-talk/

那么, 如何将 CSS 应用到 iframe 中呢?

于 2012-08-03T18:41:15.467 回答
0

我见过一些带有精致 iframe 评论表单的Blogger 模板……所以我认为这是可能的……实际上,它是 Blogger 的一个新的(我的意思是刷新,因为它可能已经存在很长时间了)评论表单皮肤。

也许它可以帮助一些人,所以这里是诀窍:

1) 确保您当前使用的是 Blogger 模板版本 2,否则,请在模板顶部使用此代码行更新它(小心,因为这会添加一些 csswidgetsection类,这可能会破坏我们的设计):

<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>

</b:skin>2)在您的 Blogger HTML 编辑器中的标记之前添加这些代码行

/* Variable definitions ====================
<Group description="New Comment Required – Dont edit">
  <Variable name="body.background" description="Body Background" type="background" color="#000" default="#000 none repeat scroll top left" value="#000 none repeat scroll top left" />
  <Variable name="body.font" description="Font" type="font" default="normal normal 14px Arial, sans-serif" value="normal normal 14px Arial" />
  <Variable name="body.text.color" description="Text Color" type="color" default="#222" value="#222222" />
  <Variable name="body.text.font" description="2" type="font" default="$(body.font)" value="normal normal 14px Arial, sans serif" />
  <Variable name="posts.background.color" description="6" type="color" default="#fff" value="#ffffff" />
  <Variable name="body.link.color" description="7" type="color" default="#ffa015" value="#ffa015" />
  <Variable name="body.link.visited.color" description="8" type="color" default="$(body.link.color)" value="#ffa015" />
  <Variable name="body.link.hover.color" description="9" type="color" default="$(body.link.color)" value="#ffa015" />
  <Variable name="blog.title.font" description="10" type="font" default="$(robotoBold45)" value="$(robotoBold45)" />
  <Variable name="blog.title.color" description="11" type="color" default="#fff" value="#ffffff" />
  <Variable name="header.icons.color" description="12" type="color" default="#fff" value="#ffffff" />
  <Variable name="tabs.font" description="13" type="font" family="$(body.font.family)" size="$(body.font.size)" default="700 normal $(size) $(family)" value="700 normal $(size) $(family)" />
  <Variable name="tabs.color" description="14" type="color" default="#ccc" value="#cccccc" />
  <Variable name="tabs.selected.color" description="15" type="color" default="#fff" value="#ffffff" />
  <Variable name="tabs.overflow.background.color" description="16" type="color" default="$(posts.background.color)" value="#ffffff" />
  <Variable name="tabs.overflow.color" description="17" type="color" default="$(posts.text.color)" value="#222222" />
  <Variable name="tabs.overflow.selected.color" description="18" type="color" default="$(posts.title.color)" value="#212121" />
  <Variable name="posts.title.color" description="19" type="color" default="#212121" value="#212121" />
  <Variable name="posts.title.font" description="20" type="font" default="$(robotoBold22)" value="$(robotoBold22)" />
  <Variable name="posts.text.font" description="21" type="font" default="$(body.text.font)" value="normal normal 14px &#39;roboto&#39;, sans-serif" />
  <Variable name="posts.text.color" description="22" type="color" default="$(body.text.color)" value="#222222" />
  <Variable name="posts.icons.color" description="23" type="color" default="#ffa015" value="#ffa015" />
  <Variable name="labels.background.color" description="24" type="color" default="$(sidebar.backgroundColorTopHD)" value="$(sidebar.backgroundColorTopHD)" />
</Group>
*/

注意:您可以在那里轻松自定义颜色和字体(原始 Blogger 强调色是#ffa015

3)全部替换 data:post.commentFormIframeSrcdata:post.commentFormIframeSrc + &quot;&amp;skin=contempo&quot; + data:variantParam

Tadam... 无需再浪费时间尝试一些 iframe 自定义。

于 2020-05-05T00:37:54.237 回答