Skip to content

Instantly share code, notes, and snippets.

@alxjrvs
Created August 14, 2012 11:06
Show Gist options
  • Save alxjrvs/3348183 to your computer and use it in GitHub Desktop.
Save alxjrvs/3348183 to your computer and use it in GitHub Desktop.
.sidebar-nav-fixed {
position:fixed;
top:100;
left:0;
}
<!-- navbar and stuff up here -->
<div class="container-fluid">
<div class="row-fluid">
<div class="span3 sidebar-width">
<div class="well sidebar-nav-fixed">
What's up, Sidebar?
</div> <!-- /sidebar -->
</div> <!-- /span -->
<div class="span9 span-fixed-sidebar">
Good place for some content
</div> <!-- /span -->
</div> <!-- /row -->
</div> <!-- /container -->
// Sticky sidebar w/jQuery
sidebarwidth = $(".sidebar-width").css('width');
bodypaddingtop = $(".navbar-fixed-top").css('height');
sidebarheight = $("body").css('height');
$('.sidebar-nav-fixed').css('width', sidebarwidth);
$('.sidebar-nav-fixed').css('height', sidebarheight);
$('body').css('paddingTop', bodypaddingtop)
contentmargin = parseInt(sidebarwidth)
$('.span-fixed-sidebar').css('marginLeft', contentmargin);
$('.span-fixed-sidebar').css('paddingLeft', 60);
@geoidesic
Copy link

Tried this on CodePen. Does nothing: http://codepen.io/anon/pen/JYBgpo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment