CSS - Setting Page Margins For Printing?
I am using PHP to generate labels and I want to print them. I am wondering if anyone could help me learn how to set the page margins? By default it looks to be printing 30px or so margins. The label sheets I am using have margins of about 5-10px. I was thinking to set margins would be something like this:
Code: <style type="text/css"> <!-- body { margin-left: 0px; margin-right: 0px; } </style> but that does not seem to work, any help out there? Thanks! Similar TutorialsAnyone come across this...? Put a minus margin as part of a class and it'll display & print OK in IE. Displays fine in Firefox but craches the browser when you try to print. I tried to isolate the code with the minus margins but it works fine on its own (see below). So it appears to be conflicting with something else on a more complex page. Sound familiar to anyone? Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style> body { font-family: Georgia, "Times New Roman", Times, serif; font-size: small; color: #666666; } p{ margin:0px; padding: 0px 0px 0.7em 0px; } .play { position:relative; font-family: Georgia, "Times New Roman", Times, serif; font-size: x-small; color: #666666; margin-left: 0px; padding-left:75px; } .character { position:relative; font-family: Georgia, "Times New Roman", Times, serif; font-weight:bold; font-size: xx-small; color: #666666; width:70px; float:left; margin-left:-75px; } </style> </head> <body> <div class="play"> <p><span class="character">Char1</span> Some line in a play.</p> <p><span class="character">Char2</span> Some other line in a play.</p> <p>That carries on for a bit.</p> <p><span class="character">Char1</span> The first person again.</p> </div> </body> </html> Hi All, I am very new to CSS and i am working on preparing a document of an existing CSS. Can someone tell me if the margins are set as this, margin:0px 31px 0px; Is it top,right and bottom? Thanks Prena I've done a lot of reading to recently learn css, but this one stumps me: I have put the one background image in the center of the page so that it looks better than being crammed in the upper left, and to keep a nice layout regardless of screen resolution. so now i want to add a text element that fits into the right place relative to the background, not the page. can i set a point (such as top-center) that all margins will be based on, besides the top and left of the browser page? the non css version of the page (with lots of tables) is at www.stipepainting.com. looking at that might clarify my question a bit. thx in advance Hi! Could some experienced CSS developer please confirm this: All paddings, and right and left margins, always combine (what I mean is if you have a left object with a 5px right margin and a right object with a 5px left margin, the distance between the two will be 10px). However, bottom & top margins never combine. Is all this true? I've got a real head-scratcher that I cannot find a solution for. The webpage I am talking about is he http://test.ecofreshusa.com/Company.aspx If you see the "breadcrumb-like" submenu (the grey one) in IE, zooming at 100% looks fine, but when you hit Ctrl+ or Ctrl- to text zoom, the margins between every line item (its made using an unordered list).. fall out and the text loses all spacing. Does anyone know where I went wrong? Any help would be much appreciated.. Oh and heres the CSS im using to work with this menu. Code: <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- #breadcrumb { position: relative; left:0px; top:0px; width:860px; vertical-align: middle; height: auto !important; background: #F0f0f0; margin-top: 0px; display: inline; } #breadcrumb_left { position:absolute; left:0px; top:0px; width:660px; height:20px; background-color: #f0f0f0; border-bottom: 1px solid #cccccc; border-top: 1px solid #f0f0f0; z-index: 10; } #breadcrumb_right { position:absolute; float: right; left:660px; top:0px; width:200px; height:20px; background-color: #F0F0F0; border-bottom: 1px solid #cccccc; border-top: 1px solid #f0f0f0; z-index: 10; } div.crumbs { margin: 0px 0px 0px 20px; float: left; font-family: Helvetica, Arial, San-serif; font-size: 10px; color: #999999; } b.crumb_title { font-family: Helvetica, Arial, San-serif; font-size: 10px; color: #999999;} .crumbs span { display: block; } .crumbs ul { display: inline; margin: 0 !important; padding: 0 !important; } .crumbs ul li { background: none; display: inline !important; margin: 0; margin-left: 20px; font-family: Helvetica, Arial, San-serif; font-size: 10px; color: #999999; line-height: 20px; } .crumbs a:link { color: #0078C2; text-decoration: none; } .crumbs a:visited { color: #0078C2; text-decoration: none; } .crumbs a:hover { color: #629D34; text-decoration:underline; } .crumbs a:active { color: #629D34; text-decoration:underline; } .crumbs img { float: none; width: 8px; height: 5px; border: 0; margin: 7px 0px 0px 20px; padding: 0; } --> </style> I have a form that users search for data. The query results are presented to them inside a table. Up until this point, there were only a handful of results in the DB and so printing was not a problem. However, now that the DB has grown, there's about a couple pages of data. When the user prints this table, only the first page gets printed. All subsequent pages are ignored. The markup looks something like below. I have 2 fieldsets - one for the form and the other for the results shown inside a table. Code: <fieldset> <form name="searchForm".....> <Insert form fields here> </form> </fieldset> <fieldset> <div id="searchResults"> <table> <INSERT header row and data rows here> </table> </div> </fieldset> I am not sure where to even begin looking for the problem. Is it an HTML issue or a CSS issue? Thanks! Hey guys, I'm working on a website and I have been notified by the client that the page does not print correctly in IE. Prints just fine in Mozilla however. I tested this and sure enough it cuts off the rightmost 100 or so pixels. The entire page exists in a table that is centered and set to be 729 pixels wide. I tried attaching an extra stylesheet: Code: <link rel="stylesheet" type="text/css" media="print" href="dummy.css"> but that has no effect. Even when I use the other stylesheet to move the content to the top left corner of the page with no borders, it still prints the page centered and lops off the rightmost 100 or so pixels. Any ideas? (telling them to print in another browser is not an option unfortunately) Hi I need to print a webpage, but I dont want it to print the date and url and title of the page on the top and bottom of the page. And also is there a way that you can print a page with buttons, without printing the buttons? Hello, I'm new to CSS. I've been developing a website in PHP. I have a report that is meant to be printed. It is formated for printing. However, if the user doesn't have his/her browser print page margins set to a max of 0.25in then some of the printed area will get clipped off. Can CSS be used to control these margins on the page? I've been looking into this and have been lead to the media = "print" area. However, it only seems to be controling the webpage's body margins and not the browser's print page setup margins. I've gotten to the point of using the following style code on my page, but now I'm at a loss as to what to try next. Code: <style type="text/css"> <!-- .style1 { font-family: Arial, Helvetica, sans-serif; font-size: 14pt; } body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 14pt; } body { margin-left: 15px; margin-top: 15px; margin-right: 15px; margin-bottom: 15px; } .style4 { font-family: Arial, Helvetica, sans-serif; font-size: 16pt; font-weight: bold; } .style15 {font-size: 10pt} .style21 {font-size: 18pt} .style24 {font-size: 24pt} .style25 {font-size: 16pt} .style28 {font-size: 12pt} --> </style> <link href="file:///C|/Webs/ures/k058_styles.css" rel="stylesheet" type="text/css"> <style type="text/css" media="print"> <!-- .style19 {font-size: 14pt} .style29 {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; } .style22 {font-size: 9pt} .style23 {font-size: 12pt; font-family: "Times New Roman", Times, serif;} .styleprint { margin: 0in 0in 0in 0in; margin-top: 0in; margin-left: 0in; } --> </style> I added the ".styleprint" style to the page only to try and control the browser's print page setup margins. What you see above are actually two attempts to do this. Like I said above the margin settings seem to only be contoling the margins on the displayed page and not the browser's print page setup margins. How can I control the browser's print page setup margins? CAN I control the browser's print page setup margins? If I cannot, what do you do to make sure that the user can print a "printer formated" page with the correct margins? Thanks, Paul I am trying to update an old site with lots of pages, I am trying to create a printing stylesheet (first time as you may guess) I have managed to exclude what I do not want to print but some text is still running off the RHS of the page. I have tried playing with page widths and margins but to no effect, any suggestions? this is what I currently have: TBODY { position: static; width: 700px; margin: 0 auto; } Hi everyone, Having some problems with CSS printing. I am trying to get a webpage to print in B4, no print margins, no header or footer. There is supposively a way to do this in CSS with the @page properties. I've tried the examples from the w3c site but to no avail. Does anyone have any code that definitely works for internet explorer? Thanks, Dave. When printing at the top there is Page 1 of 1 and at the bottom the web address comes up, is there a way to get rid of these? Regards I am having a problem where I have a <div> that holds my body image, margin: 0 auto; Inside that is my content <div> with margin:15px; but this is visually dropping the background image's margin by 15px. The problem compounds every time I add another margin/padding requirement into the rest of the <div>. Code: html, body { margin:0px; padding:0px; background-image:url(images/interface/background.png); } #body_image { width:935; margin:0 auto; padding:0px; background-image:url(images/interface/body.png); background-repeat:no-repeat; background-position:center; } #container { width:904px; height:750px; margin:15px; } #slug { height:15px; } Code: <div id="body_image"> <div id="container"> <div id="header">Header</div> <div id="nav">Nav</div> <div id="sidebar">Sidebar</div> <div id="content">Content</div> <div id="footer">Footer</div> </div> </div> The extent of my CSS is a few tutorials online and the class I took 10 years ago where the teacher said "Here's CSS, you can't do much more than change your font size and color with it... on to tables!" Thought it'd only be fair to give you a little background. Hello, I'm design the web page printing feature, i apply a print button for trigger out the window.print() javascript command and it will set the button.style.display to none after button clicked. Whereas, It is happen when user using the CRTL-P and the button will continuous remain on printing paper . I wonder any optimize way to solve this problem? Can it be solve in CSS styling? I am trying to print an HTML page in the landscape orientation using a css print style sheet. I have added the link to the style sheet in my document
Code: <link rel="stylesheet" href="print.css" type="text/css" media="print" /> the code in the stylesheet itself is Code: @page {size: landscape; margin: 0.25in;} When I print the page from Internet Explorer the settings from my browser are used. What do I need to do to have the page printed in the landscaped orientation without the user configuring their browser settings? Hi, I am trying to find a way to print address labels from a web page. The page will either be ASP or ASP.NET. Is it possible to get enough control over the print layout to create consistent labels? The browser will be IE6 and the printer will be printing onto standard address labels that you buy for this sort of thing. If it is possible, could someone please point me in the right direction, I am stumped. Thanks, Matt I have a simple page layout using div's and CSS, but the alignment becomes screwed up when printing the page. My CSS for the layout is: #OneColumn { width:575px; background:#fff; } #LeftColumn { float:left; width:458px; background:#fff; padding-top: 15px; } #RightColumn { float: right; width:113px; background:#fff; text-align:center; padding-top: 38px; font-family: Arial; font-size: 10px; color: #000; } My code is formatted in the same order so, on the actual page OneColumn is on top of the left and right columns. If the page is short (less than on page) it prints and looks fine in print preview. Problem 1: In IE 6 If the page is longer than one page when printed the information that is in OneColumn is on the first page of the printout and the rest of the information (from the left and right column) is on the next pages. Problem 2: In IE 6 and Mozilla Firefox 0.8 Also, the right column is used to display thumbnail-pics that correlate to the text in the left column. At times I used styles to space the pictures. Here is one of them: .spacePic { margin-top: 95px } This works fine except for when printing the images, they generally are printed lower than they apprear on the screen. Any suggestions or tips would be appreciated. Thanks for your help! Casey I have a report that prints a list o people and a select box that will run the same list in a form format (all on one page) so that the user can print this off and get one form per page. I am using page-break after always as part of a div that contains the info to be printed (this is a loop from a db query). On my printer and a few others it works like a charm, but I have a user that gets the first page (first loop) no problem, but after that he gets parts of the pages when he prints (they display fine on the screen in the browser - IE6). Some pages come out with half the info (the bottom half is missing. Anyone ever hear of this issue? He is using WinXP IE 6 Printer is HP 855 (or something like that) Hi, I am trying to remove the annoying url and page numbers that appear at the bottom of a page when you print a website - I want to do this using CSS so that anybody who prints my site wont get those annoying references, not change my browser. Anybody got any ideas on how to do so? Dom. I am trying to copy a pdf, and it is imperitive that the pages match up: page 1 on the pdf is page 1 on the html file when printed and so on. I am using font 12pt sizes. if it prints out correctly on my computer will it print out correctly on all since I am using the pt instead of something relative like <font size=3>? if this will not work for all then does anyone have any recomendations on how to do it? |