Q:

Make div follow screen wont work

I am trying to make that the text follows the screen when u scroll,
I have placed all my text in a div named "mydiv"
<div id="mydiv" > 
    <!-- lots of stuff in asp -->
    <table>
        <!-- table rows, etc. -->
    </table>
</div>

The Jquery
<script type="text/javascript"src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

<script type="text/javascript">
    $(document).ready(function () {

        var currentTop = parseInt($('#mydiv').css('top'));
        $(window).scroll(function () {
            var top = $(window).scrollTop();
            $('#mydiv').css('top', top+currentTop);
        });

    });

</script>

and this is my css
.mydiv{
    position:absolute;
    top:10px;
}

A:

Using position: absolute fixes it relative to the body. You want position: fixed, which fixes it relative to the window.
If you have content that is larger than the size of the box, you'll need to account for that with the overflow property, so that you will have scroll bars on the box. The user can then see all of the content, though not all at the same time of course. So your CSS would be:
.mydiv {
    position: fixed;
    top: 10px
    overflow: auto;
    height: 100%;
}

You can drop the jQuery entirely; you don't need it as long as you have position: fixed.
Note, however, that this does not work for mobile browsers, which use a viewport concept: there is a view layered over the rendered "window" and the fixed element is locked to the window, not the viewport. In that case, you will need to come up with a Javascript solution, though preferably one that only fires if you are on a mobile device.

