LoginSignup
0
0

More than 3 years have passed since last update.

n番目の子要素の色を変える

Posted at

n番目の子要素の色を変える。

・nth-child(?)を使う
・nthは1th,2th,...からくるnth

.item {
    background-color: white;
    margin: 10px;
}

.item:nth-child(even) {
    background-color: gray;
}
export const Hoge = () => {
    return (
        <>
            <ul>
                <li className="item">aaaa</li>
                <li className="item">aaaa</li>
                <li className="item">aaaa</li>
                <li className="item">aaaa</li>
            </ul>
        </>
    )
}

結果
スクリーンショット 2020-11-18 21.42.40.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0