i’m not sure if it possible: i need to apply some CSS border based on elements present inside a parent div.
These parent div are generated dinamically, so, sometimes it has 2 children (ta-1 and ta-2), and sometimes only 1 child (ta-1 or ta-2)
For example (with both):
Here i want that ta-1
has: border radius only on top, and ta-2
border radius only on bottom:
<div class="parent">
<textarea class="ta-1"></textarea>
<textarea class="ta-2"></textarea>
</div>
CSS:
.parent .ta-1 { border-top-left-radius: 50%; border-top-right-radius: 50%; }
.parent .ta-2 { border-bottom-left-radius: 50%; border-bottom-right-radius: 50%; }
But if I’ve only a child, i need to apply border radius to all 4 corners of ta-...
<div class="parent">
<textarea class="ta-2"></textarea>
</div>
CSS:
.parent .ta-1 { border-top-left-radius: 50%; border-top-right-radius: 50%; border-bottom-left-radius: 50%; border-bottom-right-radius: 50%; }
.parent .ta-2 { border-top-left-radius: 50%; border-top-right-radius: 50%; border-bottom-left-radius: 50%; border-bottom-right-radius: 50%; }
Is there a code that check if there are both children to apply radius only on 2 corner of each ta-...
, and check if there is only one ta-...
child apply to all 4 corners?
Thanks
2
Answers
You can use
:has
with:not
element of css.