Bootstrap 3RC1 + Side Panel + Affix -


can me implementing lateral panel stays visible when scrolling page using bootstrap v3 rc1?

this code bootply.

my problem when scroll down page panel shrinks, , want keep size when page on top. if write , style affix (.affix{width:10%}) can set width. if way i'll have put exact size panel.

is right approach?

the affix plugin sets different classes element based on scroll position (and offset). before offset class affix-top, between affix-offset-top , affix-offset-bottom class affix. position defined css affix-top static (default, see: http://www.w3schools.com/cssref/pr_class_position.asp) while position of affix class set fixed.

when element has position:absolute it's width max width of it's parent. in case panel 100% width of col-lg-3 (due box-sizing: border-box, see why did bootstrap 3 switch box-sizing: border-box? ). width of class 25% (3/12*100) parent .container div. (max-)width of .container depends on screen / viewport's width.

the affix class position:fixed don't have parent container. 100% width of element 100% of viewport minus left position of element (100% of available space).

when changing viewport, width of .container fixed between boundaries of grid (see: http://getbootstrap.com/css/#overview-container). size of affix-top fixed between boundaries. 25% of .container. set .affix class 25% it's size varies fluid. cause 25% of viewport (minus left) not equals 25% of container affixed element have different width class .affix.

for reason mentioned above width of affixed element set fixed value in pixels. example see docs on http://getbootstrap.com/.

the best way varies width of side panel depending on screen width (make responsive) widths in pixels in combination media queries.

example:

/* small devices (phones, 480px) */ /* no media query there no affix */  /* small devices (tablets, 768px , up) */ @media (min-width: 768px) { #side-panel { width: 152px; } }  /* medium devices (desktops, 992px , up) */ @media (min-width: 992px) { #side-panel { width: 208px; } }  /* large devices (large desktops, 1200px , up) */ @media (min-width: 1200px) { #side-panel { width: 270px; } } 

see: http://bootply.com/82661 (note adopt code bootstrap 3.0.0.)

alternative set width jquery: shows width depends on .container, prefer css solution above.

$(document).scroll(function(){     $('.panel.affix').width(((($('.container').width()+30)/4)-30)); }) 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -