Have you ever come across a website with code similar to what I've shared on this jsfiddle: https://jsfiddle.net/roa8k7js/
This particular site boasts an elaborate CSS styling sheet, exceeding 10,000 lines in length. When transitioning this website to WordPress, all the styling was successfully preserved and integrated into a theme.
However, after placing each <section>
within a wrapper, some issues arose as the styling started behaving unexpectedly.
One of the pivotal rules determining the padding for <section>
elements involves a major rule utilizing the +
selector:
#layout1 .option-b:not(.custom-bg-image) + .option-b:not(.custom-bg-img)
{
padding-top: 0;
}
The addition of wrappers has now complicated things as the +
selector no longer accurately detects the pattern:
<div class="wrapper1">
<section class="option-b">This is some text</section>
</div>
<div class="wrapper1">
<section class="option-b">This is some more text - there shouldn't be any padding on top of this one</section>
</div>
section {
border: 1px solid black;
}
#layout1 .container1>section {
padding-top: 2em;
padding-bottom: 2em;
}
#layout1 .option-b:not(.custom-bg-image)+.option-b:not(.custom-bg-img) {
padding-top: 0;
}
#layout1 .container1>.wrapper1>section {
padding-top: 2em;
padding-bottom: 2em;
}
<div id="layout1">
<div class="container1">
<section class="option-b">This is some text</section>
<section class="option-b">This is some more text - notice how there isn't a padding top on this one</section>
</div>
</div>
<div id="layout1">
<div class="container1">
<div class="wrapper1">
<section class="option-b">This is some text</section>
</div>
<div class="wrapper1">
<section class="option-b">This is some more text - there shouldn't be any padding on top of this one</section>
</div>
</div>
</div>
I am currently exploring potential solutions to adjust the CSS in order to accurately identify a <section>
within the subsequent wrapper and define the top-padding
value accordingly.
It's important to note that removing the wrappers is not an option, and all sections have already been styled correctly with them included.