当前位置: 首页 > 面试题库 >

如何在IE 6中将浮动页脚粘贴到视口的底部?

寿飞飙
2023-03-14
问题内容

我知道position:fixed会很容易,但是不幸的是,我坚持支持IE6。如何做到这一点?我宁愿使用CSS进行清理,但是如果我必须使用Javascript,那还不是世界末日。在我当前的实现中,我有一个“浮动页脚”,它浮动在主要内容区域上方,并使用Javascript定位。我现在拥有的实现即使使用Java脚本也不是特别优雅,所以我的问题是:

  1. 没有Java,有没有办法做到这一点?
  2. 如果必须使用Javascript,是否有解决此浮动页脚问题的“不错”的解决方案?“好”是指可以在浏览器中使用的东西,不会过载浏览器的资源(因为它必须经常重新计算),并且优雅/易于使用(例如,编写类似的东西会很好new FloatingFooter("floatingDiv"))。

我猜想没有一个超级简单的解决方案可以满足以上所有需求,但是我可以借鉴的东西会很棒。

最后,只是一个更普遍的问题。我知道这个问题很难解决,那么还有什么其他UI替代方法,而不是在每个页面的底部都有页脚内容?在我的特定站点上,我用它来显示步骤之间的转换。还有其他方法可以做到这一点吗?


问题答案:

这可能对您有用。我可以在IE6和Firefox 2.0.0.17上运行。试一试。为了达到效果,我使页脚的高度很高。您显然会根据需要进行更改。希望这对您有用。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Liquid Footer</title>
    <style type="text/css">
    .footer {
background-color: #cdcdcd;
height: 180px;
text-align: center;
font-size:10px;
color:#CC0000;
font-family:Verdana;
padding-top: 10px;
width: 100%;
position:fixed;
left: 0px;
bottom: 0px;
}
    </style>
    <!--[if lte IE 6]>
    <style type="text/css">
    body {height:100%; overflow-y:auto;}
    html {overflow-x:auto; overflow-y:hidden;}
    * html .footer {position:absolute;}
    </style>
    <![endif]-->
</head>

<body>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   This is to expand the content on the page<br>
   <div class="footer">-- This is your liquid footer --</div>
</body>
</html>


 类似资料:
  • null 请告知我如何实现此行为。

  • 问题内容: 我在浏览器底部放置页脚时遇到了经典问题。我尝试过包括在内的方法,但效果不佳:我的页脚始终始终显示在FF和FF中的浏览器窗口中间IE浏览器 在HTML中,我得到了这个简单的结构 这是与css页脚问题相关的css代码: 我在哪里做错了?我真的已经尝试了一切。如果我错过了任何有用的信息,请告诉我。 谢谢您提前提出任何建议。 问候, 谢谢大家的答案。它适用于: 设置位置:固定由于某种原因在IE

  • 我有多个div和其中大多数是浮在左边。如果我在页面上放置一个绝对和底部0px的位置,页脚将跳到页面的一半,并坐在内容的顶部。以下是我的HTML: 下面是我的CSS:

  • 问题内容: 如何使条形图的底部而不是顶部?现在它们粘在容器()的顶部,但我希望它们粘在底部。 如您所见,我不知道最高条的高度,所以我也不知道容器的高度。 应该简单吧?如果有帮助,它只能在不错的浏览器中工作。 PS。条的数量是可变的(在示例中不是),其高度是可变的。只有它们的宽度是静态的。定位无济于事,因为容器div没有测量值。 问题答案: 这将达到目的: 它在默认情况下已应用的父div上使用。这改

  • 问题内容: 设置网页的最佳做法是什么,以便在该网页上显示的内容/文本很少的情况下,页脚显示在浏览器窗口的底部,而不是显示在网页的中途? 问题答案: 您正在寻找的是 CSS Sticky Footer 。