Workarounds:
One option would be to add these on .import-notes
:
width: calc(100% + 20px)
position: relative;
left: -10px;
Or these, which is similar:
width: calc(100% + 20px);
margin-left: -10px;
Or just set two negative margins instead of one, so that you don't need to use calc()
:
margin-left: -10px;
margin-right: -10px;
You can see them in action here:
body {
background: lime !important;
}
.mid-section {
padding: 0 10px;
background: white;
border-color: black;
border-width: 5 px;
border-style: solid;
}
.import-notes {
/* OPTION 1 */
position: relative;
left: -10px;
width: calc(100% + 20px);
/* OPTION 2 */
/* margin-left: -10px;
width: calc(100% + 20px); */
/* OPTION 3 */
/* margin-left: -10px;
margin-right: -10px; */
background: yellow;
}
<body>
<div class="container">
<h1>Testing </h1>
<div class="mid-section">
<p>(1)This is a test </p>
<p>(2)This is a test </p>
<p>(3)This is a test </p>
<p class="import-notes">This is full width no padding</p>
</div>
</div>
</body>
✨ Actual Solution:
Alternatively, you could remove the padding from the parent and add it to the children, which looks to me more like an actual solution rather than a workaround.
What would happen if, for example, you change the <p>
for <a>
, which need to be clickable? You would need the padding to be inside it, not outside on the parent. Otherwise, the users won't be able to click on it on the sides, as they would be clicking on the parent instead.
body {
background: lime !important;
}
.mid-section {
background: white;
border-color: black;
border-width: 5 px;
border-style: solid;
}
.mid-section > p {
padding: 0 10px;
}
.mid-section > .import-notes {
background: yellow;
padding: 0;
}
<body>
<div class="container">
<h1>Testing </h1>
<div class="mid-section">
<p>(1)This is a test </p>
<p>(2)This is a test </p>
<p>(3)This is a test </p>
<p class="import-notes">This is full width no padding</p>
</div>
</div>
</body>