问题
I have a sidebar to which I am attaching a fixed class to make it sticky on scroll.
.fixed { position:fixed;top:0;bottom: 45px;min-height: 0 !important; }
But once the class gets activated the sidebar width is not working and so its messing the responsive layout once we start scrolling.
DEMO: http://jsfiddle.net/FyrRm/
I am not sure how to resize the fixed:position sidebar to fit it responsively. I tried using calc but it didn't work.
Any ideas?
回答1:
UPDATED Didn't take into account resizing from smaller to bigger
Add this to $(document).ready:
$(window).resize(function() {
$(".sticky").width($("#sidebar > img").width());
}).resize();
DEMO
来源:https://stackoverflow.com/questions/21144454/resize-width-of-positionfixed-div-to-make-it-responsive-fluid