Template:Team:DTU-Denmark/css3
From 2014.igem.org
(Difference between revisions)
Tbjohannesen (Talk | contribs) |
Tbjohannesen (Talk | contribs) |
||
Line 477: | Line 477: | ||
} | } | ||
} | } | ||
- | + | .menu { | |
- | + | background:#345; | |
- | + | color:#FFF; | |
- | + | height:2em; | |
- | + | padding:.5em; | |
- | width: 100%; | + | position:absolute; |
- | + | top:50px; | |
+ | width:100%; | ||
+ | } | ||
+ | .fixed { | ||
+ | position:fixed; | ||
+ | top:0; | ||
} | } | ||
- | |||
</style> | </style> | ||
+ | |||
+ | <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10/jquery.min.js"></script> | ||
<script> | <script> | ||
- | + | var num = 50; //number of pixels before modifying styles | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | $(window).bind('scroll', function () { | |
- | if ( | + | if ($(window).scrollTop() > num) { |
- | + | $('.menu').addClass('fixed'); | |
- | + | ||
} else { | } else { | ||
- | + | $('.menu').removeClass('fixed'); | |
- | + | ||
} | } | ||
- | |||
}); | }); | ||
+ | |||
+ | //USE SCROLL WHEEL FOR THIS FIDDLE DEMO | ||
</script> | </script> | ||
</html> | </html> |
Revision as of 11:37, 24 July 2014