Fixed elements take only absolute values as width. If your parent container is fluid (width is a percentage), you need to set the width of the fixed element dynamically. You need to get the width of the wrapping container and set it on the sticky element.
CSS
.outer {width: 25%;}
.inner {position: fixed;}
JS
var fixedWidth = $('.outer').css('width');
$('.inner').css('width', fixedWidth);
Additionally, you can add an event listener in case window resizes.
JS
window.addEventListener('resize', resize);
function resize() {
var fixedWidth = $('.outer').css('width');
$('.inner').css('width', fixedWidth);
}