Log in

View Full Version : Resolved Pseudo class syntax



marain
08-12-2018, 06:51 PM
I'm seeking center justification for the first and second columns of each row. The syntax I'm using is incorrect. Can someone please lend a hand?



table.praises-be td {
border-style: solid;
border-width: 1px;
border-color: #848482;
margin: auto;
nth-child: {text-align: center;};
nth-child(2): {text-align: center;};
}


A.

Deadweight
08-13-2018, 02:59 AM
table.praises-be td {
border-style: solid;
border-width: 1px;
border-color: #848482;
margin: auto;
}

table.praises-be td:nth-child(2) {text-align: center;}

I am not sure why you are calling 'nth-child:' so I ignored it.

marain
08-13-2018, 09:23 PM
DW,

Your solution works (as you knew it would)!

I called the nth-child because I wanted the contents of column one centered as well. So I added a line to what you provided, as follows:


table.praises-be td:nth-child(2) {text-align: center;}
table.praises-be td:nth-child(1) {text-align: center;}


I assume both lines can be combined, although when I tried to do it, CSS hiccuped.

The book I've been trying to use is less than helpful. For example, its description did not enable me to discern whether nth-child without a subscript defaults to nth-child(1). Regardless, I thank you.

A.

Deadweight
08-15-2018, 12:09 PM
You should be able to combine them to one line.

table.praises-be td:nth-child(2), table.praises-be td:nth-child(1) {text-align: center;}

I havent really heard of that happening before but I am not that pro at CSS (about the nth-child defaulting to nth 1.

marain
08-15-2018, 02:00 PM
DW,

Many thanks. I'll play with it. And, in the meanwhile, I'll mark the issue "resolved."

A.