1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ReactでBootstrapを使った際の「text-left」問題とその解決法

1
Posted at

概要

この記事では、ReactプロジェクトでBootstrapを使用する際に直面した「text-left」クラスが期待通りに動作しなかった問題について解説し、その解決法を紹介します。

問題の詳細

ReactでBootstrapのContainerとTableコンポーネントを使用して、テーブル内のテキストを左寄せにしようとしたところ、text-leftクラスが機能しませんでした。

<Container>
  <Table>
    <tbody>
      <tr>
        <th className="text-left">犬の散歩</th>
      </tr>
    </tbody>
  </Table>
</Container>

スクリーンショット 2024-10-04 16.23.58.png

解決策

調べたところ、Bootstrap 5以降では、text-leftクラスが廃止され、text-startクラスが導入されたことがわかりました。これにより、テキストを左寄せにするにはtext-startを使用する必要があります。

<Container>
  <Table>
    <tbody>
      <tr>
        <th className="text-start">犬の散歩</th>
      </tr>
    </tbody>
  </Table>
</Container>

スクリーンショット 2024-10-04 16.25.59.png

参考

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?