我正在尝试创建一个包含三个水平部分的网页 - 一个标题、一个菜单和一个内容部分。我的问题是,当我这样做时,底部 iframe 不会靠近浏览器窗口的底部。我想知道是否有人可以告诉我我做错了什么。我的 HTML 看起来像:
<!DOCTYPE html>
<html>
<head>
<style> </style>
</head>
<body>
<iframe src="title.htm" width="100%" height=90
style=" position:absolute;
top:0; left:0;
border:1px solid grey;"
name="title_frame">
<p>Your browser does not support iframes</p>
</iframe>
<iframe src="hmenu.htm" width="100%" height=70
style=" position:absolute;
top:90px;
left:0;
border:1px solid grey;
margin:0px 0px 0px 0px;"
name="hmenu_frame">
</iframe>
<iframe src="startpage.htm" width="100%" height="100%"
style=" position:relative;
top:160px;
vertical-align:bottom;
border:1px solid grey;"
name="content_frame">
</iframe>
</body>
</html>
没有 CSS 包含。我正在使用 Chrome 预览,最后一个 iframe 的底部大约是窗口的一半。我试过使用绝对位置,玩高度,并尝试垂直对齐:底部,但似乎都不起作用。
最佳答案
这是一个使用 display: flex;
和 <section>
标签而不是 iframe 的简单解决方案。宽度 flex-direction: column;
您确保您的内容部分显示在彼此的顶部,而不是在一行中。
这样,您不需要进行所有定位,并且您的标记和样式保持干净和简单。
html,
body {
height: 100%;
margin: 0;
}
body {
display: flex;
flex-direction: column;
}
section {
width: 100%;
box-sizing: border-box;
border: 1px solid grey;
}
.title {
height: 90px;
}
.hmenu {
height: 70px;
}
.content {
height: 100%;
}
<section class="title">...</section>
<section class="hmenu">...</section>
<section class="content">...</section>
关于html iframe 没有到达窗口底部,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40342224/