1

I am using css module like this ,

.catTable{
  border:1px black solid;
}

in jsx

import styles from "../css/basic-styles.module.css";
return (
  <table className={styles.catTable}>
      <tr><td>test1</td><td>test2</td></tr>
      <tr><td>test3</td><td>test4</td></tr> 
  </table>);

It works well but I want to set the css for tr too

So I made the code like this below.

in normal css I can set like this,

.catTable{
    .catTr {
        border:1px pink solid;
    } 
     border:1px black solid;
 }

in jsx

import styles from "../css/basic-styles.module.css";
return (
  <table className={styles.catTable}>
      <tr className={styles.catTr><td>test1</td><td>test2</td></tr>
      <tr><td>test3</td><td>test4</td></tr> 
  </table>);

However border of tr doesn't work, where should I change?

2
  • Does React support CSS modules instead of SASS/LESS yet?
    – tacoshy
    Commented Jul 29 at 5:30
  • @whitebear, I am not sure, but in this code you write <tr className={styles.catTr> instead of <tr className={styles.catTr}>. Maybe this can resovle your error. Commented Jul 29 at 6:07

1 Answer 1

1

You can try applying styles directly without using any class like this

.catTable{
    tr {
        border:1px pink solid;
    } 
     border:1px black solid;
 }
1
  • THank you very much I can nest the tag like this,
    – whitebear
    Commented Aug 5 at 4:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.