Is there a way to make a <div>
completely fill up a parent div, while still maintaining a 5% gap around its content? Applying the rules
width: 100%; height: 100%; padding: 5%;
achieves the desired effect for the <div>
, but causes it to exceed its parent element's bounds. How can this be done without overflowing?
I'm seeking a solution that ensures the <div>
's bounds take up 100% of its parent's and retains a 5% padding. While hacky solutions may exist, I am interested in an elegant and future-proof approach. Modern CSS technologies like Grid and Flexbox could potentially provide a cleaner solution to positioning and sizing issues with individual divs.