色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

如何在材質UI React中設置盒子組件內的項目寬度?

江奕云2年前8瀏覽0評論

我使用React材質UI和它的盒子組件來設計我的表單。 在我的例子中,我每行有4個項目,但在最后一行,我需要顯示3個項目,最后一個項目應該填充行。 換句話說,最后兩個元素必須合并。 當Box組件將我所有的行分成4列時,我該怎么做呢?

我的代碼:

<Box
    sx={{
       display: 'grid',
       columnGap: 2,
       rowGap: 3,
       gridTemplateColumns: {xs: 'repeat(7, 1fr)',
       sm: 'repeat(4, 1fr)'},
         }}
  >
first row with 4 columns:

    <TextField ....>
    <TextField ....>
    <TextField ....>
    <TextField ....>

second row with 3 columns:

    <TextField ....>
    <TextField ....>
    //This column should be spanned for two columns.
    <TextField ....>

</Box>

嘗試此網格布局:

import * as React from "react";
import { Box, TextField } from "@mui/material";

export default function Grid() {
  return (
    <Box
      sx={{
        display: "grid",
        gridTemplateAreas: "'a1 a2 a3 a4' 'b1 b2 c c'"
      }}
    >
      {/* first row with 4 columns: */}
      <TextField style={{ gridArea: "a1" }} />
      <TextField style={{ gridArea: "a2" }} />
      <TextField style={{ gridArea: "a3" }} />
      <TextField style={{ gridArea: "a4" }} />
      {/* second row with 3 columns: */}
      <TextField style={{ gridArea: "b1" }} />
      <TextField style={{ gridArea: "b2" }} />
      {/* This column should be spanned for two columns. */}
      <TextField style={{ gridArea: "c" }} />
    </Box>
  );
}