Printing in CSS

liunx

Guest
Hello, I was wondering how to link to print a single ID without printing anything else...

thanx=)<style type="text/css">
/*<![CDATA[*/
@media print {
* {
display: none !important;
}

#show {
display: block !important;
}
}
/*]]>*/
</style><div id="show">I will only be printed.</div>you are a GENIUS where did you get so good... mmmmmNo problem. :pone quick ques. though. will my code look like this? sorry if it looks confusin, im using this in an email form


$mailbody.="/*<![CDATA[*/\n";
$mailbody.="@media print {\n";
$mailbody.="* {\n";
$mailbody.="display: none !important;\n";
$mailbody.="}\n";
$mailbody.="#app-page {\n";
$mailbody.="display: block !important;\n";
$mailbody.="}\n";
$mailbody.="}\n";
$mailbody.="/*]]>*/\n";

$mailbody.="#app-page {\n";
$mailbody.="width: 8.5in;\n";
$mailbody.="height: 11in;\n";
$mailbody.="background-color: #ffffff; \n";
$mailbody.="padding: 1in 1.5in 1in 1.5in;\n";
$mailbody.="margin: 10px 0px 10px 0px;\n";
$mailbody.="}\n";


or like this:


$mailbody.="/*<![CDATA[*/\n";
$mailbody.="@media print {\n";
$mailbody.="* {\n";
$mailbody.="display: none !important;\n";
$mailbody.="}\n";
$mailbody.="#app-page {\n";
$mailbody.="display: block !important;\n";
$mailbody.="width: 8.5in;\n";
$mailbody.="height: 11in;\n";
$mailbody.="background-color: #ffffff; \n";
$mailbody.="padding: 1in 1.5in 1in 1.5in;\n";
$mailbody.="margin: 10px 0px 10px 0px;\n";
$mailbody.="}\n";
$mailbody.="}\n";
$mailbody.="/*]]>*/\n";Both look alright (you should probably go with the latter one, though). Note, however, it should be in-between a <style> tag or inside an external CSS file and then referenced somehow.would i need any special JS code to print it?

or would a normal printfunction work :

Code:
<html>
<head>
<LINK REL="StyleSheet" HREF=http://www.webdeveloper.com/forum/archive/index.php/"style/home.css" TYPE="text/css">

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}
//  End -->
</script>

</head>

<body>

<a href=http://www.webdeveloper.com/forum/archive/index.php/"javascript:printWindow()">Print This Page</a>

</body>That should work just fine. ;)Thank you, you have been very helpful.

but ive run into a problem. the JS calls to print a window, how do i print an outlook express .eml?No problem. I wouldn't worry about it too much if the script doesn't work correctly due to the fact that Outlook and any other mail client (e.g., Mozilla Thunderbird) likely has a File » Print feature of some sort rendering the script useless.what part of the print layer code would I put in my external CSS?

...and how do I reference it to print that particular layer?

Thanks,
Robert
 
Back
Top