【发布时间】:2019-09-20 11:45:30
【问题描述】:
我有一个问题,由于某种原因,网格元素的最大宽度被设置为 16%,但我不知道为什么。这是在一个使用 sass、jss 和 Material UI 的反应应用程序中。它在本地也可以正常工作,但是当我构建应用程序并将其投入生产时,问题就会出现(这使得调试变得非常“有趣”。我不太确定是什么原因造成的。
import React from "react";
// @material-ui/core components
import withStyles from "@material-ui/core/styles/withStyles";
import Grid from "@material-ui/core/Grid";
const style = {
grid: {
margin: "0 -15px",
width: "calc(100% + 30px)"
// '&:before,&:after':{
// display: 'table',
// content: '" "',
// },
// '&:after':{
// clear: 'both',
// }
}
};
function GridContainer({ ...props }) {
console.log('GridContainer', props)
const { classes, children, className, ...rest } = props;
let formattedClassName = className ? className : ''
return (
<Grid container {...rest} className={classes.grid + " " + formattedClassName + " " + 'classes-grid'}>
{children}
</Grid>
);
}
export default withStyles(style)(GridContainer);
我在应用程序的任何地方都没有 min-width: 600,所以我不确定这是从哪里来的。
任何人都知道这个问题,甚至是调试它的好方法吗? (我已经在这里待了好几个小时了)
添加 index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="apple-touch-icon" sizes="76x76" href="%PUBLIC_URL%/apple-icon.png">
<link rel="stylesheet" href="//cdn.jsdelivr.net/chartist.js/latest/chartist.min.css">
<script src="//cdn.jsdelivr.net/chartist.js/latest/chartist.min.js"></script>
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Manager</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
【问题讨论】:
-
media (min-width: 600px)来自material-ui css
标签: reactjs sass material-ui jss