Template:Team:DTU-Denmark/css3
From 2014.igem.org
(Difference between revisions)
Tbjohannesen (Talk | contribs) |
Tbjohannesen (Talk | contribs) |
||
Line 477: | Line 477: | ||
} | } | ||
} | } | ||
- | + | #ScrollMenu.fixed { | |
+ | position: fixed; | ||
+ | top: 0; | ||
+ | left: 0; | ||
+ | z-index: 1; | ||
+ | width: 100%; | ||
+ | border-bottom: 5px solid #ffffff; | ||
+ | } | ||
</style> | </style> | ||
- | <script | + | <script> |
+ | $(document).ready(function () { | ||
+ | var top = $('#ScrollMenu').offset().top - parseFloat($('#ScrollMenu').css('marginTop').replace(/auto/, 100)); | ||
+ | $(window).scroll(function (event) { | ||
+ | // what the y position of the scroll is | ||
+ | var y = $(this).scrollTop(); | ||
+ | |||
+ | // whether that's below the form | ||
+ | if (y >= top) { | ||
+ | // if so, ad the fixed class | ||
+ | $('#ScrollMenu').addClass('fixed'); | ||
+ | } else { | ||
+ | // otherwise remove it | ||
+ | $('#ScrollMenu').removeClass('fixed'); | ||
+ | } | ||
+ | }); | ||
+ | }); | ||
+ | </script> | ||
</html> | </html> |
Revision as of 11:27, 24 July 2014