See this example: https://jsfiddle.net/kevalbhatt18/w361a9hg/
When you see fiddle first strach result window. otherwise you want see what i want.
My problem is that I crate table and apply css all working fine but now i want to apply border-left: 1px dotted; to only first table.
<div class='openDiv hide'>
<table id="addPropertyValue1"></table>
<table id="addPropertyValue2"></table>
<table id="addPropertyValue3"></table>
<table id="addPropertyValue4"></table>
<table id="addPropertyValue5"></table>
</div>
I tried with first-child .but not working
.openDiv :first-child{
border-left: 1px dotted;
}
Note : dont apply css on id directly like
.openDiv #addPropertyValue1{
border-left: 1px dotted;
}
want pure css solution will help me I don't want jquery or javascript to apply dynamic class on table
Use first-child for table inside . openDiv . Updated fiddle is here. first-of-type represents the first sibling of its type in the list of children of its parent element, first-child represents any element that is the first child element of its parent.
The :first-of-type selector in CSS allows you to target the first occurence of an element within its container. It is defined in the CSS Selectors Level 3 spec as a “structural pseudo-class”, meaning it is used to style content based on its relationship with parent and sibling content.
The :first-child selector is used to select the specified selector, only if it is the first child of its parent.
How to Select the First and Last <td> in a Row with CSS. In this snippet, you can find out how to select and style individual columns of your table, particularly the first and last <td> in the table row. For that, you need to use the child selector pseudo-classes: :first-child and :last-child.
Use first-child
for table inside .openDiv
.
Like this:
.openDiv table:first-child {
border-left:1px dotted;
}
Updated fiddle is here.
Apply the css on first child
.openDiv table:first-child{
border-left: 1px dotted #000;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With