I like the idea of ββputting it in jQuery better, as Elon Zito mentioned, so you don't need to add cryptographic overrides for larger devices, following the correct pattern. for example, if you add navbar-fixed-top to the base template, then you need to set navbar-fixed-top to position:relative for xs and up the device, then set navbar-fixed-top to position:fixed; for medium and large devices, etc ...
To avoid this, you can use the bootstrap env variable, which is available, so it will work in low-resolution browsers, and not just on mobile devices, as indicated above, which makes sense when using the bootstrap. that is, you should avoid checking the device and try using media queries instead.
$(document).ready(function () { var bsEnv = findBootstrapEnvironment(); if(bsEnv != 'lg') { $('#navbar').addClass('navbar-fixed-top'); } }); function findBootstrapEnvironment() { var envs = ['xs', 'sm', 'md', 'lg']; $el = $('<div>'); $el.appendTo($('body')); for (var i = envs.length - 1; i >= 0; i--) { var env = envs[i]; $el.addClass('hidden-'+env); if ($el.is(':hidden')) { $el.remove(); return env } }; }
blamb source share