CSS Positioning: Fixed Left or Top when scrolling

Alexander

I want to create scollable divs in html and css.

My goal is the following: I have got three divs:

enter image description here

The orange div should stay at the top left.

When scrolling to the left or right (horizontal axis) I want the yellow pane as well as the blue pane to move left or right. The green and orange panes should not move left or right.

When Scrolling up or down (vertical axis) i want the green and blue pane to move up or down.The yellow and orange panes should not move up or down.

All the four divs are located in another div.

<div class="panes">
    <div class="orange"></div>
    <div class="yellow"></div>
    <div class="green"></div>
    <div class="blue"></div>
</div>

There is the Overflow css command, but I could figure out how to achive this.

Alexander

I have now figured out a solution to this by using jquery:

<!doctype html>
<html>
    <head>
    <meta charset="utf-8">
    <title>Test</title>
    <style>
    #content {
        position: fixed;
        height: 417px;
        width: 1000px;
        top: 5px;
        left: 105px;
        overflow-x: scroll;
        overflow-y: hidden;
    }

    #header {
        height: 50px;
        width: 3000px;
        background-color: yellow;
    }

    #appointments-container {
        height: 350px;
        width: 3000px;
        background-color: yellow;
        overflow-y: hidden;
        overflow-x: hidden;
    }

    #appointments {
        height: 700px;
        width: 3000px;
        background-color: lightblue;
    }

    #legend {
        position: fixed;
        top: 55px;
        left: 5px;
        height: 350px;
        width: 100px;
        background-color: lime;
        overflow-y: hidden;
    }

    #topleft {
        position: fixed;
        top: 5px;
        left: 5px;
        height: 50px;
        width: 100px;
        background-color: orange;
    }

    #scroller {
        position: fixed;
        top: 55px;
        left: 1105px;
        height: 350px;
        width: 18px;
        overflow-y: scroll;
    }

    #scroller-content{
        height: 700px;
    }
    </style>
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
  </head>
  <body>
    <div >
    <div id="topleft"></div>
    <div id="legend">
    <div id="legend-content">
        1 <br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />
        11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />
        21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />
        32<br />33<br />34<br />35<br />36<br />37<br />38
    </div>
</div>
<div>
<div id="content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1 - 1 - 1- 1 - 1 - 1 - 1 - 1- 1 - 1 - 1 - 1 - 1- 1 - 1 - 1 - 1 - 1- 1 - 1 - 1 - 1 - 1- 1 - 1 - 1 -  
        <br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />
        11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />
        21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />
        32<br />33<br />34<br />35<br />36<br />37<br />38
      </div>
    </div>
</div>
<div id="scroller">
    <div id="scroller-content">
    </div>
</div>

<script>
    $(document).ready(function(){
        $("#scroller").scroll(function() {
            var height  = $("#scroller").scrollTop();

            $("#appointments-container").scrollTop(height);
            $("#legend").scrollTop(height);
        });
    });
</script>

It is using the scroll event to capture when a pane is scrolled. And it uses scrollTop(height) to programmatically scroll the other panes.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Need a CSS solution to stay top left with page scrolling (not position:fixed)

From Dev

HTML CSS DIV Layout with Top, Left, and Right DIVs fixed with a scrolling Center DIV

From Dev

HTML CSS DIV Layout with Top, Left, and Right DIVs fixed with a scrolling Center DIV

From Dev

Table header to stay fixed at the top when scrolling

From Dev

Make menu bar fixed on top when scrolling

From Dev

DIVs flickering when positioning them fixed when scrolling inside a Div

From Dev

fixed VS absolute positioning for scrolling

From Dev

change navbar-fixed-top color when scrolling

From Dev

Positioning divs top, left, right

From Dev

CSS positioning for left nav

From Dev

HTML/CSS Float Left and Top/Bottom without position absolute/fixed

From Dev

CSS top positioning in firefox

From Dev

CSS top positioning in firefox

From Dev

scrolling horizontally with fixed left div

From Dev

positioning a fixed div under another div for scrolling

From Dev

scrolling an element on top of a fixed element

From Dev

Getting CSS left and top when div is rotated

From Dev

CSS Absolute positioning and body scrolling

From Dev

CSS Fixed position menu - scrolling issue when resizing the browser

From Dev

how to make table header freeze/fixed when scrolling in html/css?

From Dev

CSS scrolling with top overflow

From Dev

Fixed sidebar menu on the left and fixed header on top

From Dev

How to Set the Left and Top CSS Positioning of a DIV Element Dynamically Using JavaScript

From Dev

CSS absolute positioning- do I need to specify top, right, bottom AND left?

From Dev

KendoUI setting top and left with absolute positioning

From Dev

Top and left positioning not respected on some websites

From Dev

How to fixed left div once scrolling done?

From Dev

Scrolling a div with a header but keeping it fixed at 20px top when header disappears

From Dev

JQUERY: why isn't my nav fixed to the top when scrolling down?

Related Related

  1. 1

    Need a CSS solution to stay top left with page scrolling (not position:fixed)

  2. 2

    HTML CSS DIV Layout with Top, Left, and Right DIVs fixed with a scrolling Center DIV

  3. 3

    HTML CSS DIV Layout with Top, Left, and Right DIVs fixed with a scrolling Center DIV

  4. 4

    Table header to stay fixed at the top when scrolling

  5. 5

    Make menu bar fixed on top when scrolling

  6. 6

    DIVs flickering when positioning them fixed when scrolling inside a Div

  7. 7

    fixed VS absolute positioning for scrolling

  8. 8

    change navbar-fixed-top color when scrolling

  9. 9

    Positioning divs top, left, right

  10. 10

    CSS positioning for left nav

  11. 11

    HTML/CSS Float Left and Top/Bottom without position absolute/fixed

  12. 12

    CSS top positioning in firefox

  13. 13

    CSS top positioning in firefox

  14. 14

    scrolling horizontally with fixed left div

  15. 15

    positioning a fixed div under another div for scrolling

  16. 16

    scrolling an element on top of a fixed element

  17. 17

    Getting CSS left and top when div is rotated

  18. 18

    CSS Absolute positioning and body scrolling

  19. 19

    CSS Fixed position menu - scrolling issue when resizing the browser

  20. 20

    how to make table header freeze/fixed when scrolling in html/css?

  21. 21

    CSS scrolling with top overflow

  22. 22

    Fixed sidebar menu on the left and fixed header on top

  23. 23

    How to Set the Left and Top CSS Positioning of a DIV Element Dynamically Using JavaScript

  24. 24

    CSS absolute positioning- do I need to specify top, right, bottom AND left?

  25. 25

    KendoUI setting top and left with absolute positioning

  26. 26

    Top and left positioning not respected on some websites

  27. 27

    How to fixed left div once scrolling done?

  28. 28

    Scrolling a div with a header but keeping it fixed at 20px top when header disappears

  29. 29

    JQUERY: why isn't my nav fixed to the top when scrolling down?

HotTag

Archive