【发布时间】:2014-01-24 13:19:14
【问题描述】:
iframe 下方的间隙始终是边框宽度的两倍。在 Firefox 或 IE 中不会出现此问题。
jsfiddle:http://jsfiddle.net/KLH5w/
* {
margin: 0px;
padding: 0px;
/* Make box sizes include the border, which is more convenient in most cases */
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
div {
border-style: solid;
border-width: 10px;
}
iframe {
display: block;
width: 100%;
height: 100%;
border-style: dashed;
}
#frame_container {
position: absolute;
top: 50px;
bottom: 0px;
width: 100px;
}
<!doctype html>
<head>
<link rel="stylesheet" type="text/css" href="test.css">
</head>
<body>
<div id="frame_container">
<iframe></iframe>
</div>
</body>
通过将 iframe 放置在 100% 宽度/高度的 div 中,可以很容易地解决这个问题。
我猜这是一个错误,但有人有解释或优雅的 CSS 解决方案吗?
Edit1:box-sizing 似乎是问题的一部分。这是没有它的屏幕截图:
不幸的是(预计)会弄乱边框定位。
【问题讨论】:
标签: html css google-chrome iframe chromium