Jquery / css wrap text from bottom to top

I am trying to wrap text in a div using css and / or jQuery so that the bottom line is the longest.

but not

__________
|this is |
|text    |
|________|

he would say

__________
|this    |
|is text |
|________|

I can easily wrap text using

    white-space: pre-wrap;

But I can’t find anything that would allow me to do this.

(I thought that I would have to reverse the text, find where the line break occurs, apply <br/>in the same places, with the text going forward .. but I don’t know how to check where the line wraps)

+5
source share
2 answers

, , , , . , . jQuery ( , ), .

function wrapUp(element){
    width = element.width();
    string = element.text().split(' ');
    element.text('');
    reversed = string.reverse();
    var height = 0;
    for (var i=0;i<reversed.length;i++){
        reversed[i] += ' ';
        element.text(element.text()+reversed[i]);
        if (height != element.height()){
            reversed.splice(i,0,"<br/>");
            i++;
        }
        height = element.height();
        console.log(element.height());
    }
    element.html(reversed.reverse().join(''));
}
0

jquery bacon

, , , - , , .

$(".baconMe").bacon({
    'type' : 'bezier',
    'c1' : { x : 10,        y : 0  },
    'c2' : { x : -115,      y : 170 },
    'c3' : { x : 35,        y : 340 },
    'c4' : { x : 15,        y : 480 },
    'align'  : 'right'
}
+1

All Articles