Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
html の水平方向の中央揃えを行ったところ、両方を使用してボックス要素をその親の中央に配置できることに気付きました。私の質問は、これら 2 つのうちどちらが優れているかです (パフォーマンス、使いやすさなどの点で)。
divコンテナやメインページにまたはを使用する場合は、pを使用した方がよいmargin: 0px auto;ですが、2 つ以上の子を中央に配置する必要がある場合は、親をtext-align:centerに、子をに設定することをお勧めしますdisplay: inline-block。
div
p
margin: 0px auto;
text-align:center
display: inline-block