Layout breaks when Material Ui grid wrapped in div element(当 Material Ui 网格包含在 div 元素中时布局中断)
问题描述
我使用 Material Ui Grid 元素构建了响应式仪表板.并且其中一个包含在 div 元素中的网格项目会破坏布局.
I have responsive dashboard build with Material Ui Grid elements.
And one of the grid items wrapped in div element which breaks the layout.
这里是带有 div 元素的游乐场 - https://codesandbox.io/s/basicgrid-material-demo-forked-pkkil?file=/demo.js
Here is playground with div element - https://codesandbox.io/s/basicgrid-material-demo-forked-pkkil?file=/demo.js
这里是没有 div 元素的游乐场,这应该是 div - https://codesandbox.io/s/b1wsf?file=/demo.js
Here is playground without div element, and this how it should be with div - https://codesandbox.io/s/b1wsf?file=/demo.js
div 元素不能被替换或删除...
div element cannot be replaced or removed...
有什么建议吗?
推荐答案
Mui Grid 组件的设计方式是 Grid container 应该始终是 Grid 的父级项目道具.Grid container 正在克隆 Grid item 并向其传递不基于反应上下文的附加配置.
Mui Grid component is designed the way that Grid container should always be parent of Grid item prop. Grid container is cloning Grid item and passing to it additional configuration it is not based on react context.
让这个工作的唯一明智的方法是删除 div.
Only sane way to get this working is to remove div.
或者为此提供自定义 css 样式以模拟网格间距.
Or provide custom css styles to this to emulate grid spacing.
这篇关于当 Material Ui 网格包含在 div 元素中时布局中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:当 Material Ui 网格包含在 div 元素中时布局中断
基础教程推荐
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
