Last active
August 29, 2015 14:03
-
-
Save mynameispj/7ebed916fd577b452bc5 to your computer and use it in GitHub Desktop.
Bootstrap affix on smaller screens...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@media (max-width: 768px) { | |
.affix { | |
position: static; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Clamped-width. | |
* Usage: | |
* <div data-clampedwidth=".myParent">This long content will force clamped width</div> | |
* | |
* Author: LV | |
*/ | |
$('[data-clampedwidth]').each(function () { | |
var elem = $(this); | |
var parentPanel = elem.data('clampedwidth'); | |
var resizeFn = function () { | |
var sideBarNavWidth = $(parentPanel).width() - parseInt(elem.css('paddingLeft')) - parseInt(elem.css('paddingRight')) - parseInt(elem.css('marginLeft')) - parseInt(elem.css('marginRight')) - parseInt(elem.css('borderLeftWidth')) - parseInt(elem.css('borderRightWidth')); | |
elem.css('width', sideBarNavWidth); | |
}; | |
resizeFn(); | |
$(window).resize(resizeFn); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Props: http://stackoverflow.com/questions/17394854/how-can-i-disable-bootstraps-affix-on-smaller-screens