• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

div固定到浏览器底部

武飞扬头像
IT大哥哥
帮助1

在设计网站的时候,如果你某个页面的内容没有满屏,那你的footer会离浏览器底部很远,整体看起来很难看,这里用css提供一种方法来将footer固定在浏览器底部。

1.footer部分位于底部

1.footer部分位于底部,但不悬浮,当页面内容很少时,footer也始终位于底部。

<!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>纯CSS制作始终固定页面底部的DIV|www.abaonet.com|</title>
<style type="text/css">
html {
  
}
body {
        font-size:12px;
        font-family:Verdana, Arial, Helvetica, sans-serif;
        height:100%;
        position:relative;
        overflow:auto;
        margin:0;
}
.top {
     /*   position:fixed;*/
        right:0px;
        position:absolute;
        right:17px;
        bottom:0px;
        background:#000;
        color:#fff;
        border-top:1px solid #fff;
        display:block;
        width:100%;
        text-align:right;
        filter:alpha(opacity=70);       /* IE */
        opacity: .7;           /* 支持CSS3的浏览器(FF 1.5也支持)*/
        font-weight:bold;
}
.top span {
        display:block;
        position:relative;
        top:0;
        left:0;
        padding:5px;
}
.top a, .top a:link, .top a:visited, .top a:hover, .top a:active {
        color:#fff;
}
</style>
</head>
        <body>
		<div style="width:900px"></div>
        <p>position:fixed;m<sub>2</sub></p>
        <p>position:fixed;m<sup>3</sup></p>
      
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <div class="top" > <span> <a href="#top">position:fixed;</a> </span> </div>
</body>
</html>
</body>
</html>
学新通

学新通

2. footer悬浮于底部

当我们滑动鼠标时,不管怎么翻动页面,footer部分始终位于底部。

<!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>纯CSS制作始终固定页面底部的DIV|www.abaonet.com|</title>
<style type="text/css">
html {
}
body {
        font-size:12px;
        font-family:Verdana, Arial, Helvetica, sans-serif;
        margin:0;
}
.top {
        position:fixed;
        right:0px;
        bottom:0px;
        background:#000;
        color:#fff;
        border-top:1px solid #fff;
        display:block;
        width:100%;
        text-align:right;
        filter:alpha(opacity=70);       /* IE */
        opacity: .7;           /* 支持CSS3的浏览器(FF 1.5也支持)*/
        font-weight:bold;
}
.top span {
        display:block;
        position:relative;
        top:0;
        left:0;
        padding:5px;
}
.top a, .top a:link, .top a:visited, .top a:hover, .top a:active {
        color:#fff;
}
</style>
</head>
        <body>
		<div style="width:900px"></div>
        <p>position:fixed;m<sub>2</sub></p>
        <p>position:fixed;m<sup>3</sup></p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <p>position:fixed;</p>
        <div class="top" > <span> <a href="#top">position:fixed;</a> </span> </div>
</body>
</html>
</body>
</html>
学新通

学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgbcjhk
系列文章
更多 icon
同类精品
更多 icon
继续加载