1

I have a Div with 300px height and 300px width.

I want to put some text in Div so i want to check if text amount is larger that this div area make another Div tag and put rest text in it. this is possible?

Edited

or maybe this: how can i convert(for example)this text to some Div 300*300:

A fractal is a mathematical set that has a fractal dimension that usually exceeds its topological dimension[1] and may fall between the integers.[2] Fractals are typically self-similar patterns, where self-similar means they are "the same from near as from far"[3] Fractals may be exactly the same at every scale, or as illustrated in Figure 1, they may be nearly the same at different scales.[2][4][5][6] The definition of fractal goes beyond self-similarity per se to exclude trivial self-similarity and include the idea of a detailed pattern repeating itself.[2]:166; 18[4][7]

As mathematical equations, fractals are usually nowhere differentiable, which means that they cannot be measured in traditional ways.[2][6][8] An infinite fractal curve can be perceived of as winding through space differently from an ordinary line, still being a 1-dimensional line yet having a fractal dimension indicating it also resembles a surface.[1]:48[2]:15

The mathematical roots of the idea of fractals have been traced through a formal path of published works, starting in the 17th century with notions of recursion, then moving through increasingly rigorous mathematical treatment of the concept to the study of continuous but not differentiable functions in the 19th century, and on to the coining of the word fractal in the 20th century with a subsequent burgeoning of interest in fractals and computer-based modelling in the 21st century.[9][10] The term "fractal" was first used by mathematician Benoît Mandelbrot in 1975. Mandelbrot based it on the Latin frāctus meaning "broken" or "fractured", and used it to extend the concept of theoretical fractional dimensions to geometric patterns in nature.[2]:405[7]

result must be some thing like this:

enter image description here

KF2
  • 9,887
  • 8
  • 44
  • 77
  • 1
    try the accepted answer from [this question](http://stackoverflow.com/questions/3238515/javascript-detect-scrollbar-in-textarea), it should give you a good starting point – Zathrus Writer Sep 24 '12 at 12:12
  • @Zathrus Writer:exactly i want to generate my html code before show it and i want to split my string data to (div 300*300)if text was larger than div area generate another div tag – KF2 Sep 24 '12 at 12:18

1 Answers1

3

Try something like the following:

var str = "This is a very long string. You don't know exactly how much width you will need for it to be displayed";
var ar = str.split(" ");
var index = 0;
var $test = $("#test");

while($test.height() < 300){
    console.log($test.height());
 $test.html($test.html() +" "+ ar[index++]); 
    if(!ar[index]){break;}  
}

var fits = ar.splice(0,index-1);
$("#fixed").html(fits.join(" "));
$("#overflow").html(ar.join(" "));

This should be a good starting point for you.

Example

edit: extended example

Christoph
  • 50,121
  • 21
  • 99
  • 128