简体   繁体   中英

Add a new div once the height exceeds certain amount of pixels?

I need to divide the pages that are going to be printed, so I decided to get the max amount of height pixels everytime that a div is added and then when it reaches, For example, between 700px and 720px, it'll add another header to it, which means that it's the second page that will print.

The problem is that the height of each div it's gonna be different like:

<div id="1"> <!-- example: height:40px--> </div>
<div id="2"> <!-- height:20px --> </div>

It's will be a undefined height that depends on the amount of text that will come from the Database.

I can't do onload on the body because the divs would be already loaded and onload doesn't work with divs.

I still can't figure out a way to do it, any ideas would be appreciated

I'm using Classic ASP with VBscript here(if it helps for something)

Thanks!

'Determine the max numbers of characters you can fit into your div s, then from your page generation script split your content in multiple divs. for exemple with PHP:

<?php
// Suppose the content is within the variable data and the max-length is 500 charcaters
$i = 1;
while ($data) {
    echo '<div id="' . $i++ .'">'. substr($data, 0, 500) . "</div>";
    $data = substr($data, 500);
}
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM