/    Sign up×
Community /Pin to ProfileBookmark

Printing in CSS

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

thanx=)

to post a comment
CSS

10 Comments(s)

Copy linkTweet thisAlerts:
@fredmvFeb 28.2004 — <style type="text/css">
/*<![CDATA[*/
@media print {
* {
display: none !important;
}

<i> </i> #show {
<i> </i> display: block !important;
<i> </i> }
<i> </i>}
/*]]&gt;*/
&lt;/style&gt;
&lt;div id="show"&gt;I will only be printed.&lt;/div&gt;
Copy linkTweet thisAlerts:
@webmorpheusauthorFeb 28.2004 — you are a GENIUS where did you get so good... mmmmm
Copy linkTweet thisAlerts:
@fredmvFeb 28.2004 — No problem. :p
Copy linkTweet thisAlerts:
@webmorpheusauthorFeb 28.2004 — one quick ques. though. will my code look like this? sorry if it looks confusin, im using this in an email form
<i>
</i>
$mailbody.="/*&lt;![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.="/*]]&gt;*/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:
<i>
</i>
$mailbody.="/*&lt;![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.="/*]]&gt;*/n";
Copy linkTweet thisAlerts:
@fredmvFeb 28.2004 — Both look alright (you should probably go with the latter one, though). Note, however, it should be in-between a [font=courier]<style>[/font] tag or inside an external CSS file and then referenced somehow.
Copy linkTweet thisAlerts:
@webmorpheusauthorFeb 28.2004 — would i need any special JS code to print it?

or would a normal printfunction work :

[code]
<html>
<head>
<LINK REL="StyleSheet" HREF="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="javascript:printWindow()">Print This Page</a>

</body>
Copy linkTweet thisAlerts:
@fredmvFeb 28.2004 — That should work just fine. ?
Copy linkTweet thisAlerts:
@webmorpheusauthorFeb 28.2004 — 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?
Copy linkTweet thisAlerts:
@fredmvFeb 28.2004 — 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 [b]File &raquo; Print[/b] feature of some sort rendering the script useless.
Copy linkTweet thisAlerts:
@IndependentAug 20.2006 — 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
×

Success!

Help @webmorpheus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...