css3 selector, nth child incrementing by 1
-
26-12-2019 - |
Question
i am using css3 selector to select different childs . is their any alternative instead of hardcoding it
.checkout_main .check_tr th:nth-child(1){
width:50px;padding-left:10px;
}
.check_tr th:nth-child(2){
width:300px;padding-left:10px;
}
.check_tr th:nth-child(3){
width:50px;padding-left:10px;
}
.check_tr th:nth-child(4){
width:100px;padding-left:10px;
}
Solution
There are two alternatives
You can use odd even
:nth-child(odd)
{
width: 100px;
}
:nth-child(even)
{
width:200px;
}
Another way is you have to formulate an+b . Then it works, Let me know your html. Ii ll try and tell you an+b form.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow