Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 材质UI:不支持的非无单位线高度与栅格对齐。请改用无单位线高度_Css_Reactjs_Material Ui - Fatal编程技术网

Css 材质UI:不支持的非无单位线高度与栅格对齐。请改用无单位线高度

Css 材质UI:不支持的非无单位线高度与栅格对齐。请改用无单位线高度,css,reactjs,material-ui,Css,Reactjs,Material Ui,在许多ReactJs项目中,其中一个错误如下: Error: Material-UI: unsupported non-unitless line height with grid alignment. Use unitless line heights instead. 在px中定义线宽时,下面是我的代码: const breakpoints = createBreakpoints({}); let theme = createMuiTheme({ typography: {

在许多ReactJs项目中,其中一个错误如下:

Error: Material-UI: unsupported non-unitless line height with grid
alignment. Use unitless line heights instead.
px
中定义线宽时,下面是我的代码:

const breakpoints = createBreakpoints({});

let theme = createMuiTheme({
     typography: {
        allVariants: {
            fontFamily
        },
        h1: {
            fontWeight: 600,
            fontSize: 26,
            lineHeight: '32px',
            [breakpoints.down("sm")]: {
                fontSize: 18,
                lineHeight: '26px',
            }
        },
        h2: {
            fontWeight: 600,
            fontSize: 20,
            lineHeight: 28 / 20
        },
        h3: {
            fontWeight: 600,
            fontSize: 16,
            lineHeight: '22px',
            [breakpoints.down("sm")]: {
                fontSize: 14,
                lineHeight: '20px',
            }
        }
    }
})
在上面的示例中,如果我将
h1
h2
lineHeight
更改为
px
值,它会抛出一个错误,但不会为
h3
抛出一个错误,而是在
px
或无单位值中定义线宽

上面的代码引发错误,因为我在
px
中定义了
h1
的线宽,如果我将其更改为下面的代码,我将开始工作:

h1: {
    fontWeight: 600,
    fontSize: 26,
    lineHeight: 32 / 26
},

告诉我为什么会这样。我搜索了StackOverflow,但没有找到任何相关问题。

可能是您在代码中的某个地方使用了,因为它包含

由于以下原因,
h3
没有发生错误:


if(remFontSize您是否在某处使用
responsiveFontSize
?@RyanCogswell,是的,我在排版中使用媒体查询。谢谢,但我没有在我的项目中添加此条件,可能是材质UI正在这样做。我提供了指向材质UI代码中此条件来源的确切位置的链接。它位于
responsiveFontSize中s
函数。哦,太棒了,但是为什么material要添加这个条件呢?
responsiveFontSizes
使用主题中的初始字体大小作为最大字体大小,然后根据它计算最小字体大小。我想它希望避免产生任何开始时的

    if (remFontSize <= 1) {
      return;
    }