Frage

I have a question,that would be the best solution to print a webpage.For example, I have a website with news,I need to print only the news and picture,and remove the menu,header and footer.I want to do this in CodeIgniter.

War es hilfreich?

Lösung

You said you want to this in CodeIgniter. I don't think you need any server side code for this. Try below suggestion.

You can use @media query.

In your default css without using external stylesheet you can do this:

@media print {
    #with_print {
        display: none;
    }
}

Hide your header, footer and menu withing @media print block

With external stylesheet add media="print" attribute to <link> tag.

<link href='printCSS.css' rel='stylesheet' media="print" type='text/css'>

With external stylesheet you don't need to add @media query block in your printCSS.css.

See the Demo

See the print preview from your browser and where the text says: I will be hidden when you try to print me, cannot not be seen on the print preview page.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top