如何在 iframe 周围创建边框?

新手上路,请多包涵

我正在尝试为 wordpress 上的某些 conetnt 添加边框,并且因为我不知道如何添加 css 文件,所以我试图在 html 中做所有事情(或者至少我认为是 html)。我对编码的了解是在我高中时期留下的。

这是我要围绕其创建 1 或 2 像素的简单黑色边框的内容:

 <iframe src="https://link_to_my_file/file.pdf" style="width:1000px; height:300px;" frameborder="1"></iframe>

然而,这是行不通的。所以我尝试了这种方式:

 <iframe src="https://link_to_my_file/file.pdf" style="width:1000px; height:300px;" frameborder="1"></iframe> <style> iframe.solid {border-style:solid} </style>

但这也没有用。

如何在不必使用单独的 css 文件的情况下以正确的方式放置内容?

原文由 simple mind 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 458
2 个回答

如果你想使用内联 HTML 样式:

  <iframe src="https://link_to_my_file/file.pdf"
    style="width:1000px; height:300px; border: 1px solid black;"></iframe>

原文由 filipbarak 发布,翻译遵循 CC BY-SA 3.0 许可协议

输出在代码段中不起作用。在 HTML5 中弃用的属性 <iframe>

滚动

框架边框

对齐

longdesc

边距宽度

而不是将它们用作 iframe 内联属性,您可以在 css 中使用它

演示:

 iframe{
border:4px solid red;
}
 <iframe src="https://www.google.co.in/?gfe_rd=cr&dcr=0&ei=WyV_WvDBOY_E8wfHmba4Aw"></iframe>

访问此链接以获取有关已弃用属性的更多信息

https://html.com/tags/iframe/

原文由 Nihal 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏