reactjs - CssBaseline 类有什么作用?
问题描述
我一直想知道 Material-UI React 库中的CssBaseline类是做什么的,但我似乎无法在任何地方找到答案,而且我链接的页面并没有对类的作用做太多解释。这里有人知道这个组件应该做什么吗?
解决方案
CssBaseline
是添加到<head />
文档中的一种 CSS 重置。如果您熟悉类似的方法,例如normalize.css,它会为默认元素添加一些默认视觉样式、重置填充等...
Material-UI 提供了一些重置样式,你可以在这里观察到CssBasline.js主要box-sizing
和正文字体颜色和background
颜色
'@global': {
html: {
WebkitFontSmoothing: 'antialiased', // Antialiasing.
MozOsxFontSmoothing: 'grayscale', // Antialiasing.
// Change from `box-sizing: content-box` so that `width`
// is not affected by `padding` or `border`.
boxSizing: 'border-box',
},
'*, *::before, *::after': {
boxSizing: 'inherit',
},
'strong, b': {
fontWeight: 'bolder',
},
body: {
margin: 0, // Remove the margin in all browsers.
color: theme.palette.text.primary,
...theme.typography.body2,
backgroundColor: theme.palette.background.default,
'@media print': {
// Save printer ink.
backgroundColor: theme.palette.common.white,
},
},
推荐阅读
- php - Laravel“属于”功能。不完全确定这是如何工作的。帮助从 Blade 模板访问相关模型信息
- java - CodenameOne - 为 XCode 注入 plist 值的构建提示无法通过构建过程
- tabulator - 制表符 - 为空单元格设置样式
- android - Android Canvas:如何在 Line Draw 上添加阴影?
- macos - Multipass 在 MacOS 和 multipassd 错误日志上完全崩溃
- node.js - Multer 文件上传在服务器上以 500 退出,但在 localhost 上工作(使用 Postman 测试)
- c# - 从 C# 添加新行时如何在 GridView 中添加删除链接?
- reactjs - 即使我将所有组件都放在了关键位置,也会出现唯一的关键错误
- encoding - 在 Mule4 中无法识别 DataWeave Multipart/form-data 输入编码
- flutter - getData 数组为空