I have a parent with children of a . when the mouse over user changes the color of the frame for children to red. it works.
My problem is that the length of the child is not static. he is dynamic. I add the left border of radius both first and last , but how to add right-radius to second and last ? (since I do not know the number of children)
.parent { border:5px solid red; display:inline-block; position: relative; border-radius:5px; box-sizing:border-box; margin-bottom:3em; } .parent a { display:block; padding:1em; border-bottom:1px solid #ddd; position: relative; width:50%; float:left; box-sizing:border-box; } .parent a:nth-child(odd):hover{ border:5px solid #ddd; margin: -5px; } .parent a:nth-child(even):hover{ border:5px solid #ddd; margin: -5px; left:10px; } .parent a:first-of-type{ border-top-left-radius:5px; } .parent a:last-of-type{ border-bottom-left-radius:5px; }
<div class="parent"> <a href="#">1</a><a href="#">2</a><a href="#">3</a><a href="#">4</a><a href="#">5</a> </div> <div class="parent"> <a href="#">1</a><a href="#">2</a><a href="#">3</a> </div> <div class="parent"> <a href="#">1</a> </div>
or what is the right way to handle this?
source share