Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Position absolute to top of page.

    Hi all.

    I'm trying to get a simple page of text to print with lines always on the same spot, over multiple pages (printed on paper). I've got the first page fine with using CSS absolute positioning. However, I would like to not have to setup CSS elements for each page, when they will be the same. I would like to be able to reference the page break. Just like I referenced the top of the document.

    Please help me out.

    Thanks

    John.

  • #2
    Regular Coder Kevin_M_Schafer's Avatar
    Join Date
    Apr 2011
    Location
    Fairfax, Minnesota, U.S.A.
    Posts
    482
    Thanks
    97
    Thanked 17 Times in 17 Posts
    Hi dude2,

    Welcome to CodingForums.

    You can call up the same CSS in as many pages as you want.

    Simply put this line of code at the top of your html page, in the head area, and you can use the same CSS for unlimited pages.

    Code:
    <link rel="stylesheet" href="css/main.css" />
    Be sure to change the "href" to your path.

    Is this what you have in mind?

    --Kevin

    .
    My keyboard is an IBM from 1993 and I like it that way. | Who is Dan Well? Everyone always says I know Dan Well.Building a web page is like building a birdhouse. Put it up there and watch 'em come. | Maintaining the aspect ratio of an image is more important than having a cold orange pop.

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for getting back to me so quickly.

    When I say multi-page, I mean a long document that would take multiple pages to print on actual 8.5x11 paper.

    How about that?

  • #4
    Regular Coder Kevin_M_Schafer's Avatar
    Join Date
    Apr 2011
    Location
    Fairfax, Minnesota, U.S.A.
    Posts
    482
    Thanks
    97
    Thanked 17 Times in 17 Posts
    Okay, I see. Well, I'm new to page breaks, so please hang around a bit and we'll hope a more experienced coder jumps in the discussion. You came to the right place.

    --Kevin

    .
    My keyboard is an IBM from 1993 and I like it that way. | Who is Dan Well? Everyone always says I know Dan Well.Building a web page is like building a birdhouse. Put it up there and watch 'em come. | Maintaining the aspect ratio of an image is more important than having a cold orange pop.

  • #5
    New to the CF scene
    Join Date
    Feb 2012
    Location
    http://www.tabloal.com
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for comment

  • #6
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sinner_ View Post
    thanks for comment
    Thanks for useless response

  • #7
    Registered User
    Join Date
    Jun 2011
    Posts
    1,063
    Thanks
    12
    Thanked 241 Times in 240 Posts
    Quote Originally Posted by dude2 View Post
    I'm trying to get a simple page of text to print with lines always on the same spot, over multiple pages (printed on paper). I've got the first page fine with using CSS absolute positioning. However, I would like to not have to setup CSS elements for each page, when they will be the same. I would like to be able to reference the page break. Just like I referenced the top of the document.
    I don't understand any of this. Try posting your full code or a link to your website. Off the top of my head, I would say that position: absolute; is relative to the <body> tag. But if you use position: relative; on something within the body tag, it becomes it's own piece. Anything position: absolute; within that piece is relative to that piece instead of the <body>

    A mockup:

    Code:
    <!DOCTYPE html>
    <html>
    	<head>
    		<style type="text/css">
    			p {
    				position: absolute;
    				top: 0;
    				background: #EEE;
    			}
    		</style>
    	</head>
    	<body>
    		<p>This is position: absolute; top: 0;</p>
    		<div style="position: relative; margin: 50px;">
    			<p>This is also position: absolute; top: 0;, but RELATIVE to the position of the div</p>
    		</div>
    	</body>
    </html>
    for more reading: http://css-tricks.com/absolute-posit...e-positioning/
    Last edited by Sammy12; 02-07-2012 at 11:39 PM.

  • #8
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Thanks for the great reply.

    I have found a work-around using fpdf for php to generate a pdf document. The formating option is great and strait forward in fpdf.

    Thanks for everyone's help. I'm sure I'll be back!

    -John


  •  

    Posting Permissions

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