我正在为body要构建的网页元素使用100%的高度,以便能够为所包含的元素设置成比例的高度,以控制它们的高度以及其背景图像的显示。
在滚动网页时使用Bootstrap附加插件控制元素的位置时(如果html, body { height:100% }已定义),附加元素的行为将不符合预期。它似乎无法预料地跳到页面上。
这是一个代码示例。卸下,html, body { height: 100%; }使固定的元件正常工作。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap Affix Tutorial</title>
<!-- Bootstrap -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 …Run Code Online (Sandbox Code Playgroud)