How to flow text from DIV to DIV?

后端 未结 3 1044
旧巷少年郎
旧巷少年郎 2021-01-05 07:21

I have two DIVs with absolute position on two sides of a HTML page such as (EXAMPLE)

3条回答
  •  爱一瞬间的悲伤
    2021-01-05 07:39

    so far (2012) It's not possible using CSS, CSS3 (with 2 separate elements)

    but using JS You can clone the content and use scrollTop on the right element :

    LIVE DEMO

    var d = document,
        $left  = d.getElementById('left'),
        $right = d.getElementById('right'),
        leftH  = $left.offsetHeight;
    
    $right.innerHTML = $left.innerHTML +'

    '; $right.scrollTop = leftH;

    As you can see I'm appending also an empty paragraph, to fix the right element need to scrollTop some amount of px

    Note: add overflow:hidden; to your ID elements #left and #right

提交回复
热议问题