+ -
当前位置:首页 → 问答吧 → 关于自动高度与下边距的问题

关于自动高度与下边距的问题

时间:2011-10-27

来源:互联网

HTML code

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>右页面</title>
<style>
* { margin:0; padding:0px;}
body {
    height:100%;
}
#top-content{
    margin:0px 4px 20px 4px;
    position:absolute;
    height:100%;
    background:#A7E8B7;
    width:139px;
    display:block;
    border:#666 1px solid;
}
</style>
</head>

<body>
<div id="top-content"></div>
</body>
</html>



有什么办法使top-content这个div按浏览器高度拉伸且距离下边缘一个固定的高度

作者: greedisgood5000   发布时间: 2011-10-27

HTML code
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
* { margin:0; padding:0px;}
body {
    height:100%;
}
#top-content{
    margin:0px 4px 20px 4px;
    position:absolute;
    bottom:20px;
    height:100%;
    background:#A7E8B7;
    width:139px;
    display:block;
    border:#666 1px solid;
}
</style>
</head>

<body>

<div id="top-content"></div>

</body>
</html>




是这样 下边距 有距离吗

作者: ssdltwp   发布时间: 2011-10-27

楼上的下边距是40px,而不是20px
HTML code
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
* { margin:0; padding:0px;}
body {
    height:100%;
}
#top-content{
    margin:0px 4px 0px 4px;
    position:absolute;
    bottom:20px;
    height:100%;
    background:#A7E8B7;
    width:139px;
    display:block;
    border:#666 1px solid;
}
</style>
</head>

<body>

<div id="top-content"></div>

</body>
</html>


这样下边距才是20px

作者: a87345293   发布时间: 2011-10-27

引用 2 楼 a87345293 的回复:

楼上的下边距是40px,而不是20px
HTML code
<!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">
<……

bottom我是试过的,边距是有了,但是实际效果这个div的上面消失了,难道没有其他办法吗?

作者: greedisgood5000   发布时间: 2011-10-27

二楼正解啦

作者: fuguojian   发布时间: 2011-10-28

热门下载

更多