• All geek questions in one place

    Is it possible to lock the div along the x axis but scroll along the y axis?

    HTML

    <div id="header">
        <ul id="nav">
           <li><a id="ho" href="#spread1-anchor">Home</a> /</li>
           <li><a id="bg" href="#spread2-anchor">Background</a> /</li>
           <li><a id="ap" href="#spread3-anchor">Approach</a> /</li>
           <li><a id="se" href="#spread9-anchor">Services</a> /</li>
           <li><a id="cl" href="#spread10-anchor">Clients</a> /</li>
           <li><a id="co" href="#spread11-anchor">Contact</a></li>
        </ul>
    </div>
    
    <div id="container">
    <!-- Very wide horizontal scrolling content-->
    </div>
    

    CSS

    #header {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    }
    #container {
    width: 8000px;
    height: 590px;
    /*etc*/
    }
    

    Using the code above, I have a very wide #containerone that scrolls horizontally using ScrollTo.js. And the #headerone that controls it is in a fixed position since I don't want it to scroll along with the rest of the page / container. My problem is that if you resize the windshield vertically, the container is hiding under #headerdue to a fixed position.

    Is it possible to fix #headerhorizontally, but still scroll vertically? Using jQuery or CSS?

    My live example is here: http://www.kargo2.com/Stackover/

    Thank.

    +3
    jquery css xhtml scrollto
    Karlgoldstraw 07 . '10 15:42
    2

    :

    $(window).scroll(function(){
        $('#header').css({
            'top': $(this).scrollTop() + 15
        });
    });
    

    :

    #header {
        top: 15px;
        left: 15px;
        position: absolute;
    }
    

    15px , , , , , .

    +1
    lonesomeday 07 . '10 17:57

    position fixed absolute top: 0; left:0;

    0
    Jacob McDonald 07 . '10 16:50

    Source: https://habr.com/ru/post/1773506/

    More articles:

    • How to compile Erlang application into binary executable and run it? - erlang
    • Creating animations using embedded javascript - javascript
    • Rails RESTful to delete in nested resources - rest
    • Exact semantics of getRowData ()? - java
    • Rails application helper does not support Chinese characters - ruby ​​| fooobar.com
    • Если rake spec в Rspec 3 всегда заканчивается "rake aborted" - rspec2
    • manipulate a list in mathematics with select - wolfram-mathematica
    • working with complex arrays of other programmers in PHP - arrays
    • Search in multidimensional array (PHP) - php
    • Where Now for Enterprise Windows Mobile Applications - windows-ce

    All Articles

    Geek Questions | 2019