| <!DOCTYPE html> |
| |
| <html> |
| <head> |
| <style> |
| .box { |
| height: 100px; |
| width: 100px; |
| margin: 10px 0; |
| background-color: blue; |
| -webkit-transform: translateZ(0); |
| } |
| |
| .leaf { |
| background-color: green; |
| } |
| </style> |
| <script type="text/javascript" charset="utf-8"> |
| |
| function makeDeepTree(depth, host) |
| { |
| var parent = host; |
| var innerElement; |
| for (var i = 0; i < depth; i++) { |
| var currElement = document.createElement("div"); |
| currElement.className = 'box'; |
| parent.appendChild(currElement); |
| parent = currElement; |
| innerElement = currElement; |
| } |
| innerElement.classList.add('leaf'); |
| } |
| |
| function doTest() |
| { |
| makeDeepTree(500, document.getElementById('deep')); |
| } |
| |
| window.addEventListener('load', doTest, false); |
| </script> |
| </head> |
| <body> |
| <div id="before" class="leaf box"></div> |
| <div id="deep" class="box"></div> |
| <div id="after" class="leaf box"></div> |
| </body> |
| </html> |