Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm using the following code to hide the left hand navigation in SharePoint:

<style type="text/css">
 #s4-leftpanel {
    display:none !important;
 }
 .s4-ca{
    margin-left:0px !important;
 }
</style>

This works great but the issue is when the page loads you can initially see the left hand menu for a few seconds but the code kicks in and it gets hidden. I don't want to see the menu on page load for a few seconds. Is that possible?

EDIT: I should have mentioned more details. I'm doing this within a custom web part. I only want the left hand navigation gone when this web part is applied to a page. I put this CSS within the web part itself.

share|improve this question
    
How did you apply the CSS code? –  Sig Weber Mar 2 '12 at 20:34
    
Through a custom web part. –  daver306 Mar 2 '12 at 21:06
add comment

1 Answer

up vote 3 down vote accepted

You should insert your style inside "head" tag of page.

By the code you can do it so:

Page.Header.Controls.Add(new LiteralControl("<style type=""text/css""> #s4-leftpanel {display:none !important;} .s4-ca{ margin-left:0px !important;} </style>"));
share|improve this answer
    
I should have mentioned more details. I'm doing this within a custom web part. I only want the left hand navigation gone when this web part is applied to a page. I put this CSS within the web part itself. I updated the original question to reflect this. –  daver306 Mar 2 '12 at 21:12
    
I have added an example. –  Aviw Mar 2 '12 at 21:15
    
Cheers! I had to wrap the CSS elements with a <style> tag but it worked great. Thank you! –  daver306 Mar 2 '12 at 21:23
    
Oh, sure. I have forgotten about style tag, sorry. :) –  Aviw Mar 2 '12 at 21:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.