So, if you want the my_line
to be the same size as the wrapper
and shrink when you resize the window use this approach :
.wrapper {
width: 100%;
max-width: 1200px;
margin: 0 auto;
}
.wrapper .my_line {
width: 100%;
}
That way wrapper
will have 100% of the browser but be limited and always centered. While the my_line
will inherit the full width.
So, when you resize, to less than 1200px the wrapper
and my_line
will shrink with the window.
EDIT:
If you want the my_line
to be bigger than the wrapper
, why placing it inside the wrapper
? Just place it above or underneath of the wrapper
.
The solution you got works anyways if you change the HTML. The problem with your solution is that if you later add position: relative
to the wrapper
it won't work. While if you change the HTML structure so that my_line
is direct children of the body
it will still work.