SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: print div

  1. #1
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    print div

    I have lots of divs positioned on my page. If there is one div that contains the "main content" of the page, can I somehow create a print link that will only print that area? I want something easily dynamic.

  2. #2
    .net install meltdown
    Join Date
    May 2001
    Location
    View Ridge
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could specify a different stylesheet to use when printing:

    <link rel="stylesheet" type="text/css" media="screen" href="style.css">

    <link rel="stylesheet" type="text/css" media="print" href="style_print.css">

    The first one will be used to apply style in the browser the second one will be used only when printing.

    In your print stylesheet set the visibility:none; for the divs you don't want to print and change the margin,width etc. for the div you do want to print for the desired printed result.

    HTH

  3. #3
    SitePoint Wizard Ian Glass's Avatar
    Join Date
    Oct 2001
    Location
    Beyond yonder
    Posts
    2,384
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd use "display: none;" as the visibility one will still have the divs as white space.

    You could also use the @media or @page so you don't have to create multiple style sheets. None of the media formatting in CSS work for NS4 and earlier or earlier than IE4, I think.

  4. #4
    .net install meltdown
    Join Date
    May 2001
    Location
    View Ridge
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Ian Glass
    I'd use "display: none;" as the visibility one will still have the divs as white space.
    Woops...Ians right. Sorry, guess I shouldn't post after staring at code all day

  5. #5
    SitePoint Wizard Ian Glass's Avatar
    Join Date
    Oct 2001
    Location
    Beyond yonder
    Posts
    2,384
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by isotope235
    Woops...Ians right. Sorry, guess I shouldn't post after staring at code all day
    And what I don't? Excuses, excuses... Pitiful :-p


Bookmarks

Posting Permissions

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