我正在寻找有关如何将具有 15 像素顶部边距的 div 设置为 min-height:100% 的建议?我想要的是 div 触摸屏幕底部(不触发滚动条),但是当内容太大而不适合时,它会自动扩展到屏幕限制以下,触发滚动条。到目前为止,这是我得到的:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
body, html{height:100%; margin:0;}
body{background:#AAA}
#main{position:relative; width:970px; margin:0 auto; border:solid 1px #666; background:#FFF; margin-top:15px; min-height:100%;}
</style>
</head>
<body>
<div id="main">
try duplicating this content until it does not fit in the box
</div>
</body>
</html>
最佳答案
你可以使用下面的css将div固定在底部
#main{position:fixed; bottom : 0px; width:970px; margin:0 auto; border:solid 1px #666; background:#FFF; margin-top:15px; min-height:100%;}
关于html - 非常简单的 CSS 最小高度 100% 边距问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8872849/