Bootstrap - Column with position fixed.
by Kyle Mitofsky
HTML
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://getbootstrap.com/dist/css/bootstrap.css">
<div class="container">
<div class="row">
<div class="col-xs-8 content">Content</div>
<div class="col-xs-3 col-xs-offset-1 sidebar-outer" >
<div id="sidebar-static">
Static <br/>
Width: <span id="width-placeholder-static"></span>px
</div>
</div>
</div>
</div>
<br/><br/>
<div class="container">
<div class="row">
<div class="col-xs-8 content">Content</div>
<div class="col-xs-3 col-xs-offset-1" id="sidebar-outer" >
<div id="sidebar-relative">
Relative: <br/>
Width: <span id="width-placeholder-relative"></span>px
</div>
</div>
</div>
</div>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<!-- Post Info -->
<div style='position:fixed;bottom:0;left:0;
background:lightgray;width:100%;'>
About this SO Question: <a href='http://stackoverflow.com/q/23616847/1366033'>Adding a responsive image to a position fixed div within a Bootstrap column</a><br/>
Fork This Skeleton Here <a href='http://jsfiddle.net/KyleMit/kcpma/'>Bootrsap 3.0 Skeleton</a><br/>
<div>
CSS
.container {
background-color: #f2f2f2;
}
.content {
background-color: #a9a8a8;
}
.sidebar-outer {
position: relative;
}
/* Static */
#sidebar-static {
background: yellow;
position: fixed;
width: 25%;
}
@media (min-width: 768px) {
#sidebar-static {
width: 158px; /* 632 * .25 */
}
}
@media (min-width: 992px) {
#sidebar-static {
width: 213px; /* 852 * .25 */
}
}
@media (min-width: 1200px) {
#sidebar-static {
width: 263px; /* 1052 * .25 */
}
}
/* Relative */
#sidebar-relative {
background: yellow;
}
JavaScript
$(function() {
$(window).resize(function() {
$('#width-placeholder-relative')
.html($("#sidebar-relative").width());
$('#width-placeholder-static')
.html($("#sidebar-static").width());
}).resize();
});