Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2010
    Thanked 1 Time in 1 Post

    Defining pagewidth


    I just made an iframe RTF editable by using some JavaScript, and a button to print the iframe's content. What I would like to know is if there is any way to specify an iframe's (or div's) width using CSS, so that line breaks occur on the same spot on the printed version as they do on the screen.

    Pixels, %, em's and ex's all rely on the screen. But if I'd like to make the iframe fit for A4 paper (±20x30cm), 20cm would seem huge on the screen, so does anyone know a solution?

    I'd appreciate it.

  • #2
    Regular Coder mbaker's Avatar
    Join Date
    Jan 2010
    Burford, Oxfordshire, United Kingdom
    Thanked 39 Times in 39 Posts
    I have not done this, but if I were confronted with this problem, this is what I'd do:

    Set up separate style sheets for screen and print. [There may be common parts that you could put in a third stylesheet for both screen and print, but lets ignore that part for now.]

    In the print stylesheet set the font size and printable area to something that works for A4.

    Create some test pages that use the full width of the page and print them using your newly created print stylesheet.

    In the screen stylesheet set the font size you want to use on screen and set the width of the screen that is going to be used for your content.

    View your test pages. Adjust the width of the content area until you get wrapping occurring in exactly the same place as on your printed pages.
    - Michael Baker - HTML Tags Guide - Reference and Tutorials
    - Like voting, validate early, validate often - W3C HTML Validator - W3C CSS Validator
    - Wot? me cynical? no, its just if you vote, er, validate early, you have more chance of validating often.


    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts