iframe身体移除空间 [英] iframe body remove space

查看:148
本文介绍了iframe身体移除空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iframe的样式为 style =width:100%,它几乎涵盖了页面宽度。但它在左侧和右侧留下了一小部分。所以我添加了 body {margin:0px; } 删除空格。

My iframe a style of style="width:100%", and it almost covers the page width. But it leaves a small margin on the left and right side. So I added body { margin:0px; } to remove the space.

它有效,但问题是删除< body>上的边距。 会影响其他内容,例如< p> 中的段落< body>

It works, but the problem is that removing the margin on <body> affects other things, for example a paragraph <p> inside <body>.

有没有办法只为< iframe> 消除保证金?

Is there a way to eliminate the margin only for the <iframe>?

代码:

<!DOCTYPE html>
<html>
<body>
<p> hello </p>
<iframe src="http://www.weather.com" style="width:100%; height:95%; margin:0px"></iframe>
</body>
</html>


推荐答案

你应该这样做:

body{margin:0} // remove body margin

iframe{margin:0;width:100%}//remove iframe margin

p,div{margin:10px} //append margin to p and other tags

针对您案例的演示:

<!DOCTYPE html>
<html>
<head>
<style>
    body{margin:0}
    iframe{margin:0;width:100%}
    p{margin:10px}
</style>
</head>
<body>
    <p> hello </p>
    <iframe src="http://www.weather.com" style="width:100%; height:95%; margin:0px"></iframe>
</body>
</html>

这篇关于iframe身体移除空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆