I am trying to find out how to make an element's width N% larger than its parent (or a particular percentage of the viewpoint).
So far I found the following snippet from an answer https://stackoverflow.com/a/24895631/54929 However, no matter how I modified the values to calc( )
I haven't quite figured out how to get e.g. an element 25% bigger than its parent (or 75% of window width) etc and have it centered.
body,
html,
.parent {
height: 100%;
width: 100%;
text-align: center;
padding: 0;
margin: 0;
}
.parent {
width: 50%;
max-width: 800px;
background: grey;
margin: 0 auto;
position: relative;
}
.child-element {
position: relative;
width: 100vw;
left: calc(-50vw + 50%);
height: 50px;
background: blue;
}
<div class='parent'>
parent element
<div class='child-element'>child-element</div>
</div>