Continuing overflowed text in a different div?

前端 未结 6 584
刺人心
刺人心 2020-11-30 14:31

What I am trying to do is create a site that displays my rants in faux letter form.

I want the \"paper size\" (div size) to be fixed, and the text to continue on the

6条回答
  •  忘掉有多难
    2020-11-30 15:00

    I came up with a small JS Script that might help you out. It's far from perfect, but might give you a decent starting point. Essentially, it loops through your large text and looks for a scrollbar to appear. You may need to alter the calculations just a bit.

    JSFiddle http://jsfiddle.net/Tt9sw/2/

    JS

    var currentCol = $('.col:first');
    var text = currentCol.text();
    currentCol.text('');
    var wordArray=text.split(' ');
    
    $.fn.hasOverflow = function() {
       var div= document.getElementById($(this).attr('id')); 
       return div.scrollHeight>div.clientHeight;
    };
    
    for(var x=0; x

    HTML

    Lorem Ipsum ....... LONG TEXT .......

    CSS

    .col{
       width:200px;
       float:left;
       height:200px;
       border:1px solid #999;
       overflow:auto;
       font-family:tahoma;
       font-size:9pt;
    }
    

    UPDATE

    For this example, you must include the jQuery Libray in your scripts.

    
    

    PS - if you get to know jQuery, you will start to use it for everything. It greatly increases cross-browser compatibility and simplifies many common tasks.

提交回复
热议问题