开发者

How to hide text with CSS when printing a page [duplicate]

This question already has answers here: 开发者_如何学C Closed 11 years ago.

Possible Duplicate:

How do I hide an element when printing a web page?

I would lilke to hide text on a page when the visitor prints.

The text resideds in a

<tr><td>Don't show me</td></tr>

It is not wrapped in a DIV ID, or Class... so I am wondering with CSS can you hide this portion of text... ?? Would you use CSS selectors?


Use the @print media type in your css to assign a specific styling (like display: none) to prints only.


You can hide it if you can select it but based on just one line of html it´s impossible to say whether you can just select that table cell.

I think adding something like a no_print class is your safest bet.

Obviously in combination with a print-specific style-sheet.


To do this, simply add

    @media print {

   .dontPrint {
       display:none;
    }

    }

Then in the part you dont want to print add class="dontPrint"

So for you, you could just do the following

<tr><td class="dontPrint">Don't show me</td></tr>

Now that part won't print

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜