如何设置 Javascript 代码片段的样式
我想将此 Javascript 片段(来自 AWeber 的网络表单)嵌入到我的网站中:
我的网站使用该样式p { 行高:1.5em; }
。不幸的是,这也适用于 Javascript 片段,使其看起来很愚蠢。
我如何告诉 Javascript 代码段使用 1em 而不是 1.5em 的行高?
我尝试了这个,但它不起作用:
<p style="line-height: 1em;">
<script type="text/javascript" src="http://forms.aweber.com/form/49/522310949.js"
</script>
</p>
我还考虑使用 Javascript (document.getElementById('p').style.lineHeight = '1 em';
) 来更改 CSS,但正如我了解 Javascript 会修改整个网站,而不仅仅是一个元素......
你能帮忙吗? 提前致谢!
I want to embed this Javascript snippet (webform from AWeber) into my website:<script type="text/javascript" src="http://forms.aweber.com/form/49/522310949.js"></script>
My site uses the style p { line-height: 1.5em; }
. Unfortunately this is also applied to the Javascript snippet and makes it look stupid.
How can I tell the Javascript snippet to use a line-height of 1em instead of 1.5em?
I tried this but it doesn't work:
<p style="line-height: 1em;">
<script type="text/javascript" src="http://forms.aweber.com/form/49/522310949.js"
</script>
</p>
I also considered using Javascript (document.getElementById('p').style.lineHeight = '1 em';
) to change the CSS, but as I understand Javascript modifies the whole website and not only one element...
Can you please help?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您需要更多样式,我发现您生成的块也使用这些样式:
af-header
、af-body
、af-footer
、af-element
和af-textWrap
。但是,如果您需要更通用的解决方案,请参阅@Pointy的答案。
In case you need more styling, I see that your generated block also uses these styles:
af-header
,af-body
,af-footer
,af-element
andaf-textWrap
.However, if you need a more universal solution, refer to @Pointy's answer.
将表单放入
中是没有意义的,因为
不能包含块级元素。使用
正如 @Max 隐式指出的那样,添加 CSS 来设置内容样式会“更好”。
您可以使用 Firebug 或 Chrome/Safari 开发人员工具来检查“实时”页面元素的样式。这可以帮助您找出特定元素以特定方式呈现的原因,并且还可以让您尝试对样式进行更改。
编辑也许是这样的:
Putting the form inside a
<p>
does not make sense, as<p>
cannot contain block-level elements. Use a<div>
instead:As @Max implicitly noted, it'd be "nicer" to add CSS to style the content.
You can use Firebug or the Chrome/Safari developer tools to examine the styles of "live" page elements. That can help you figure out the reasons that particular elements look a particular way, and it also lets you play around with alterations to the styles.
edit maybe something like: