Juan Camacho Juan Camacho - 4 months ago 7
jQuery Question

How can I create a static <div>?

I would like create a static

<div>
, if user uses the scroll, the
<div>
must be still.

Context: I am working in a project and I need three static components, I managed to make two components but as I am using JSF, Primefaces and Bootsfaces (bootstrap and JQuery), the third component must be different. The thrid component must be a typical
<div>
.

My code:
1. html:

<div id = "divProyecto">
....
</div>


2. css:

#divProyecto{
background-color: blue;
height: 50px;
margin-top: 10px;
width: 100%;
display: block;
border: solid #222222 1px;
}


3. js (I found this code, but doesn't work):

$(document).ready(function () {
$('#divProyecto').scrollToFixed();
});


This image resume all: http://s2.subirimagenes.com/imagen/9622798algo.gif
The image show as the black boxes don't move, but blue box move with scroll.

Thanks you!

Answer

You should use position: fixed;

And specify the

top: 100px;
left: 100px;

http://jsfiddle.net/tovic/fwkWG/

Comments