I need to apply CSS to first and last child.
Here is my code:
<div class="parent">
<div class="A B"><div class="xyz"></div></div>
<div class="A B"><div class="xyz"></div></div>
<div class="A B"><div class="xyz"></div></div>
</div>
.parent {
display: inline-block;
width: 100%;
}
.A {
display: inline-block;
max-width: 75%;
position: relative;
clear: both;
}
.B {
float: left;
padding: 10px;
}
I was trying to do as following:
.parent:first-child {
margin-top: 15px;
}
.parent:last-child {
margin-bottom: 2px;
}
So that first child top margin becomes 15px and gap between all the child become 4px;
But it's not working. Kindly help me to solve this problem.