Check demo here: https://jsfiddle.net/fedek6/78mL1ora/
Here’s a method to create horizontal color fill preloader using svg, js and a bit of CSS.
This trick will help you place element inside its cointainer using absolute positioning. Very often you want to be very precise when placing elements. It is very hard/impossible when you anchor to entire window because browser resizing is messing everything up. To avoid this, simply set relative positioning to the wrapper element. Check demo.