修复网页中的文字

时间:2011-01-31 17:35:23

标签: html

我想要我的文字,例如。 “注册”是最顶层的文本,是一个标题,在屏幕上保持固定,然后当我滚动“注册”时,屏幕顶部应保持原样,滚动时所有其他文本应在其下方。我怎样才能做到这一点????请尽快回复...感谢您提前的所有时间。

5 个答案:

答案 0 :(得分:2)

您可以在CSS中使用position: fixed;。除了IE6之外,它几乎被所有浏览器都认可......但你不应该尝试让东西在那里工作。

.stayOnTop
{
  position: fixed;
  top: 0; /* to place it on top */
  left: 0; /* to place it in the left corner, that'd be the most logical place; although this obviously isn't necessary, you could want to put it in the right corner or somewhere else and whatever /longcomment */
}

答案 1 :(得分:2)

我不确定我是否正确理解你想要实现的目标,但我会试一试。如果您尝试创建固定位置标题,则可以使用与固定页脚相同的技术。您可以在此fixed footer documentation

中找到更多信息

这里是示例代码:

<!-- IE in quirks mode -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<title>Fixed footer</title>
<style type="text/css">
 body{
  margin:0;
  padding:0 0 <length> 0;
 }
 div#footer{
  position:absolute;
  bottom:0;
  left:0;
  width:100%;
  height:<length>;
 }
 @media screen{
  body>div#footer{
   position: fixed;
  }
 }
 * html body{
  overflow:hidden;
 } 
 * html div#content{
  height:100%;
  overflow:auto;
 }
</style>
<div id="footer"> footer </div>
<div id="content"> content </div>

答案 2 :(得分:1)

您可能希望为此设置css属性position to fixed。当然,对于大多数系统上的大多数浏览器而言,这种行为在某些情况下很常见,只需使用标记!

答案 3 :(得分:1)

您应该在css中将元素的position属性设置为“fixed”。

#registration_element
{
position:fixed;
top:0px;
}

this link should help

答案 4 :(得分:1)

使用样式位置:固定。

这是一个例子。

<style>
#idOfDiv {
    position: fixed;
    width: 100px;
    background: #FFF;
    z-index: 999;
}
</style>
<div id="idOfDiv"> TEST </div>