簡體   English   中英

<tablerow> styles 不適用於<tablecell></tablecell></tablerow>

[英]<TableRow> styles not applying to <TableCell>

我想為<TableRow> <TableRow>應用了“fontWeight”,希望這種樣式將應用於其中的每個單元格。 但它沒有發生。

// demo.js

<TableRow sx={{ fontWeight: "300" }}> {/*  Not applied to table cells under this tag*/}
  <TableCell sx={{ fontWeight: "300" }}> {/* Applying successfully */}
    Dessert (100g serving)
  </TableCell>
  <TableCell align="right">Calories</TableCell>
  <TableCell align="right">Fat&nbsp;(g)</TableCell>
  <TableCell align="right">Carbs&nbsp;(g)</TableCell>
  <TableCell align="right">Protein&nbsp;(g)</TableCell>
</TableRow>

<TableCell>應用fontWeight是有效的,但為什么在<TableRow>上應用 styles 不會影響它的孩子?

CodeSandbox演示

因為<th>默認有font-weight: 500 你必須覆蓋它 如果你想讓它們繼承,你可以這樣做: font-weight: inherit; 到表格單元

子級從父級繼承樣式,前提是它沒有在自身中應用該樣式

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM