fixing text in webpage
i want that my text eg. "registration" which is the topmos开发者_如何学Ct text and is a heading,to remain fixed on the screen and then when i scroll "registration" should remain intact at the top of the screen and all other text should go beneath it while scrolling. how can i do this???? please reply soon... Thanks to all for your time in advance.
I'm not sure do I understand correctly what you are trying to achive, but i'll give it a shot. If you are trying to create fixed position header you can use the same technique like in fixed footer. You can find more info in this fixed footer documentation
And here goes the example code:
<!-- 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>
You can use position: fixed;
in CSS. It's recognized by pretty much every browser, except for IE6... but you shouldn't try to make stuff work there anyway.
.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 */
}
You want probably want to set the css attribute position to fixed for this. Of course this behaviour is somewhat commonly seen with most browsers on most systems simply with the tag!
You should set your element's position property to "fixed" in your css.
#registration_element
{
position:fixed;
top:0px;
}
this link should help
Use style position:fixed.
Here comes the example.
<style>
#idOfDiv {
position: fixed;
width: 100px;
background: #FFF;
z-index: 999;
}
</style>
<div id="idOfDiv"> TEST </div>
精彩评论