HTML: <iframe> width 属性

由网友 大卫 发布 阅读 6

HTML: <iframe> width 属性

本文介绍HTML iframe wwidth属性以像素为单位指定 <iframe>的宽度,在线实例演示如何使用HTML iframe width 属性、浏览器的兼容性、语法定义及它的属性值详细资料等。

 HTML <iframe> 标签

在线示例

指定高度480像素、宽度为280像素的<iframe>:

<!DOCTYPE html>
<html>
<head>
<title>HTML:<iframe> width 属性 - 大卫编程网 div.cn<https://cdn.div.cn/static/uploads/code/2023-02-21/a5d127cc44ff064c638041ab062eab95.jpgtitle>
<body>
<iframe src="https://cdn.div.cn/static/uploads/code/2023-02-21/a5d127cc44ff064c638041ab062eab95.jpg" width="480" height="280">
<p>Your browser does not support iframes.<https://cdn.div.cn/static/uploads/code/2023-02-21/a5d127cc44ff064c638041ab062eab95.jpgp>
<https://cdn.div.cn/static/uploads/code/2023-02-21/a5d127cc44ff064c638041ab062eab95.jpgiframe>
<https://cdn.div.cn/static/uploads/code/2023-02-21/a5d127cc44ff064c638041ab062eab95.jpgbody>
<https://cdn.div.cn/static/uploads/code/2023-02-21/a5d127cc44ff064c638041ab062eab95.jpghtml>测试看看 ‹https://cdn.div.cn/static/uploads/code/2023-02-21/a5d127cc44ff064c638041ab062eab95.jpg›

浏览器兼容性

IEFirefoxOperaChromeSafari

所有主流浏览器都支持 width 属性。

定义和用法

width属性以像素为单位指定<iframe>的宽度。

HTML 4.01 与 HTML5之间的差异

在HTML 4.01中,宽度可以以像素或包含元素的百分比定义。在HTML5中,该值必须以像素为单位。

语法
<iframe width="pixels">

属性值
描述
pixels以像素为单位的宽度(比如 "200px" 或者只是 "200")。  HTML <iframe> 标签

HTML: <frame> frameborder 属性 HTML: <iframe> seamless 属性