vendredi 22 août 2014

[Bootstrap] Sticky left sidebar

Apply affix (http://getbootstrap.com/javascript/#affix) and scrollspy (http://getbootstrap.com/javascript/#scrollspy)


body {
   position: relative;
}

<body data-spy="scroll" data-target=".mynav">
   <div class="row">

      <div class="col-md-3 mynav">
         <ul class="nav nav-pills nav-stacked" data-spy="affix" data-offset-top="60" data-offset-bottom="200">
            <li>
               <a href="#menu1">menu1</a>
            </li>
            <li>
               <a href="#menu2">menu2</a>
            </li>
         </ul>
      </div> <!--div col-md-3-->

      <div class="col-md-9">
         <div id="menu1">
            blabla
         </div>
         <div id="menu2">
            blabla
         </div>
      </div> <!--div col-md-9-->

   </div> <!--div row-->
</html>

jeudi 21 août 2014

[Bootstrap] Sticky footer

http://stackoverflow.com/a/25075517


 $(document).ready(function () {
//http://stackoverflow.com/a/25075517
            var $docH = $(document).height();
            // The document height will grow as the content on the page grows.
            $('.my-footer').css({
                /*
                The default height of .navbar is 50px with a 1px border,
                change this 52 if you change the height of your footer.
                */
                top: ($docH - 52) + 'px'
            });
        });



 <div id="footer" class="my-footer">
      <div class="container">
        <p class="text-muted credit">toto.com</p>
      </div>
    </div>

[Bootstrap] How to create a sticky left sidebar menu

http://www.bootply.com/82265#
http://www.bootply.com/90936#

mercredi 20 août 2014

[Python] How to check if an object has an attribute : hasattr vs __dict__

class A(object):
   foo = 1

class B(A):
   pass


b = B()
print( hasattr(b, 'foo') )
True

print( 'foo' in b.__dict__)
False


hasattr : checks on super class
__dict__ : does not include super class

Categories