最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Css position fixed for horizontal scroll but scroll vertically - Stack Overflow

programmeradmin3浏览0评论

I have three div as below :

<div id="left"></div>
<div id="center"><table></table></div>
<div id="right"></div>

Now what i need to do is to keep #left and #right fixed for horizontal scroll and scroll #center only. This is working with css position:fixed for #left and #right. But the problem is when i scroll html page vertically i need all the div's i.e. #left,#centerand #right to scroll. This is not working. Please anyone help me how to do it so that #left and #right scrolls vertically along with #center and remains fixed for horizontal scroll. I have no clue how to do it using css and make it work.

I have three div as below :

<div id="left"></div>
<div id="center"><table></table></div>
<div id="right"></div>

Now what i need to do is to keep #left and #right fixed for horizontal scroll and scroll #center only. This is working with css position:fixed for #left and #right. But the problem is when i scroll html page vertically i need all the div's i.e. #left,#centerand #right to scroll. This is not working. Please anyone help me how to do it so that #left and #right scrolls vertically along with #center and remains fixed for horizontal scroll. I have no clue how to do it using css and make it work.

Share Improve this question asked Jan 11, 2013 at 9:10 user850234user850234 3,46315 gold badges52 silver badges84 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 12

Try this link, it uses a plugin called scrollspy to do the stuff. Pretty easy...

http://www.rickyh.co.uk/css-position-x-and-position-y/

Also, see this SO question: CSS: fixed position on x-axis but not y?

Thanks to semir.babajic : here is the actual snippet. You will need jQuery.

$(window).scroll(function(){
    $('#header').css({
        'left': $(this).scrollLeft() + 15 //Always 15px from left
    });
});
发布评论

评论列表(0)

  1. 暂无评论