Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Different style sheet for printing

Status
Not open for further replies.

Mike Lewis

Programmer
Jan 10, 2003
17,516
Scotland
I have created a web page which includes a navigation bar down the left hand side. When the page is printed, I'd like to suppress this bar.

My normal style sheet includes the following code:

Code:
.sidebar
{
  width: 15%;
  float: left;
  margin: 0;
  padding: 0;
}

I apply this to the DIV that holds the navigation bar.

I have also created a second style sheet, for use with printed output. Here, the above code has been modified as follows:

Code:
.sidebar
{
  width: [b]0%[/b];
  float: left;
  margin: 0;
  padding: 0;
  [b]visibility:hidden;[/b]
}

The result is that the navigation bar does not appear during printing, which is what I want. But, in its place, I get a wide margin, extending across the left-most 8 cm of the page.

Is there any way I can hide the sidebar, and get the main text to start printing near the left-hand side of the page? Is my overall approach correct, or is there some better way of hiding elements during printing?

Thanks in advance.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I think I've solved it.

Instead of:

visibility:hidden;

I used:

display:none;

It looks better now. I'll experiment some more. In the meantime, I'd still be interested in hearing any comments on whether my overall approach is the best way.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I think that is a reasonable conclusion. Great job on figuring this out!
 
[tt]visibility: hidden;[/tt] hides the element -- it makes it invisible. Still, the element occupies the same space it would if it were visible. Just like you still bump in all the invisible people on your way to work.

However, [tt]display: none;[/tt] simply instructs the renderer to not create that element in the first place. Since the element does not get rendered, it does not take up any space. In your case, you were looking for display property.

___________________________________________________________
[small]Do something about world cancer today: PACT[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top