如何在 iframe 周围创建边框?

how do i create a border around iframe?

我正在尝试为 wordpress 上的某些内容添加边框,并且因为我不知道如何添加 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 文件的情况下以正确的方式放置内容?

输出在代码段中不起作用。 在 HTML5 中为 <iframe>

弃用的属性

滚动

frameborder

对齐

longdesc

边距宽度

您可以在 css

中使用它们,而不是将它们用作 iframe 内联属性

演示:

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

访问此 link 了解已弃用属性的更多信息

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

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

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

只需将边框声明添加到 iframe 标记内的 style=""。

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