...

View Full Version : Position absolute to top of page.



dude2
02-07-2012, 09:28 PM
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.

Kevin_M_Schafer
02-07-2012, 09:43 PM
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.


<link rel="stylesheet" href="css/main.css" />

Be sure to change the "href" to your path.

Is this what you have in mind?

--Kevin

.

dude2
02-07-2012, 09:47 PM
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?

Kevin_M_Schafer
02-07-2012, 09:58 PM
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

.

sinner_
02-07-2012, 10:24 PM
thanks for comment

dude2
02-07-2012, 11:30 PM
thanks for comment

Thanks for useless response

Sammy12
02-07-2012, 11:34 PM
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:



<!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-positioning-inside-relative-positioning/

dude2
02-09-2012, 09:01 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum