开发者

css percentage print question

开发者 https://www.devze.com 2023-03-30 10:49 出处:网络
<!DOCTYPE HTML> <html> <head> <style type=\"text/css\"> body { margin:0; padding:0;
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
    body {
        margin:0;
        padding:0;
    }
    dev {
        position: absolute;
        top: 10%;
    }
</style>
</head>
<body>
<dev>

<!-- needs a couple of pages to print this -->

</dev&开发者_运维百科gt;
</body>
</html> 

%s/dev/div/g

When I print this, the 10 % from the top: 10% is related to the size of one printed page?


When dealing with prints, it's not recommended using percentages at all, I would recommend using other (Solid) units such as pt or cm, to make it align perfectly, remember, print is not web, the page size will not change, 10% is not fluid like in a browser. I'd make simple measurements with a ruler and use absolute units.

As for your question

Yes, it will work, 10% will be 10% from the top of one page.


If you % a tag that spans multiple pages, i believe it only does the the top % in the first instance. Despite there being multiple pages when printing, creates one giant page. You would have to find the cut off points for each page and close then open a new tag there (i think you mean not ) although this isn't very good practice.


To answer your question, yes... 10% should be from the top of one page, assuming that the element fits on one page.

However in my experience, percentages do not work well for print styles.

If possible, it is best to set your styles with pt (point), which is the measurement designed for print, or px (pixel).

0

精彩评论

暂无评论...
验证码 换一张
取 消