如何更改reddit的嵌入评论iframe的最大宽度?

时间:2016-06-29 17:04:09

标签: javascript html css iframe reddit

Reddit提供了在网站上嵌入评论的代码,

例如:



<div class="reddit-embed" data-embed-media="www.redditmedia.com" data-embed-parent="false" data-embed-live="false" data-embed-uuid="24a3e666-f855-4664-8e9e-9d040fef3ca6" data-embed-created="2016-06-29T16:56:02.732Z">
  <a href="https://www.reddit.com/r/Showerthoughts/comments/2safxv/we_should_start_keeping_giraffes_a_secret_from/cno7zic">Comment</a> from discussion <a href="https://www.reddit.com/r/Showerthoughts/comments/2safxv/we_should_start_keeping_giraffes_a_secret_from/">We should start keeping giraffes a secret from young children. Imagine discovering giraffes exist when you were like 15. &quot;Woah! Check out that long necked horse!&quot;</a>.
</div>
<script async src="https://www.redditstatic.com/comment-embed.js"></script>
&#13;
&#13;
&#13;

将其粘贴到HTML后,会向内容呈现iframe

max-width

iframe属性设置为800px,如何将其更改为其他值或none

Fiddle

1 个答案:

答案 0 :(得分:1)

为了覆盖您无法访问的内联样式,您需要使用!important(这是您需要使用!important的极端情况,否则避免它

&#13;
&#13;
iframe {
  max-width: none !important
}
&#13;
<div class="reddit-embed" data-embed-media="www.redditmedia.com" data-embed-parent="false" data-embed-live="false" data-embed-uuid="24a3e666-f855-4664-8e9e-9d040fef3ca6" data-embed-created="2016-06-29T16:56:02.732Z"><a href="https://www.reddit.com/r/Showerthoughts/comments/2safxv/we_should_start_keeping_giraffes_a_secret_from/cno7zic">Comment</a> from discussion <a href="https://www.reddit.com/r/Showerthoughts/comments/2safxv/we_should_start_keeping_giraffes_a_secret_from/">We should start keeping giraffes a secret from young children. Imagine discovering giraffes exist when you were like 15. &quot;Woah! Check out that long necked horse!&quot;</a>.</div>
<script
async src="https://www.redditstatic.com/comment-embed.js"></script>
&#13;
&#13;
&#13;