I have an image inside a container. The image should always be at full browser width (100vw). As my layout is responsive, and the container has a fixed width at a certain point (45em), I can't simply use negative margins. So I got an idea, but as a novice I can't seem to achieve it...
This is what I want to do:
- Check the body width
- Check the container width
- Subtract the element width from the body width
- Divide this number in two
- Add this number as a negative margin to an element
This is what I got so far...
var bodyWidth = $('body').width(); //Check the body width
var elemWidth = $('#content').width(); //Check the container width
var margin = bodyWidth-elemWidth; //Subtract the element width from the body width
I still need to divide the number in two, and add this number as a negative margin to an element.
Help is much appreciated.