I would like to have some nested divs with a different colour border which have a repeating pattern.
E.g. I could have 5 colours, red, blue, green, yellow, orange
I would like to have the same effect as below would give, but using a css only based on the position of the DIV rather than actually having to add a class name onto each div
<div class="redBorder">
<div class="blueBorder">
<div class="greenBorder">
<div class="yellowBorder">
<div class="orangeBorder">
<div class="redBorder">
<div class="blueBorder">
<div class="greenBorder">
<div class="yellowBorder">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
This is similar to the question posted here, but I would like to specify the colours used at each nth step.
Repeating a set of colors on nested divs with CSS
I have tried the following from the examples given...
<style>
div {
border: 2px solid #ccc;
border-top: 5px solid #ccc;
padding: 5px;
padding-top: 50px;
border-radius: 5px;
}
div {
border-color: linear-gradient(
to right,
red calc(0 * 100% / 4) calc(1 * 100% / 4),
blue calc(1 * 100% / 4) calc(2 * 100% / 4),
green calc(2 * 100% / 4) calc(3 * 100% / 4),
yellow calc(3 * 100% / 4) calc(4 * 100% / 4)
)
calc(var(--x) * 100% / 3) 0/400% 100%;
}
</style>
With the following markup, but this has not worked
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>