我正在尝试从文本框中删除填充,但问题是它来自 Material UI。
我为所有类设置了 padding 0,但 padding 仍然没有被删除。
你能告诉我如何删除这个填充吗?
.MuiOutlinedInput-input-1708 {
padding: 18.5px 14px;
}
这是我的代码和一个沙箱:
https://codesandbox.io/s/m58841kkwp
cssLabel: {
"&$cssFocused": {
color: { borderColor: "red", padding: 0 }
}
},
cssFocused: { borderColor: "red", padding: 0 },
cssUnderline: {
"&:after": {
borderBottomColor: "red",
padding: 0
}
},
// cssOutlinedInput: {
// "&$cssFocused $notchedOutline": {
// borderColor: "green"
// }
// },
cssOutlinedInput: {
"& $notchedOutline": {
//add this nested selector
borderColor: "red",
padding: 0
},
"&$cssFocused $notchedOutline": {
borderColor: "green",
padding: 0
}
},
notchedOutline: { borderColor: "red", padding: 0 },
原文由 user10509524 发布,翻译遵循 CC BY-SA 4.0 许可协议
解决它的一种方法可能是创建一个有用的类并覆盖材料文本字段的样式。这样你就可以重用它
我离开这个例子 https://stackblitz.com/edit/react-textfield-without-padding
注意: 我给它留了 5px 的内边距,以使其看起来更好。您可以自定义它,这样您就没有填充
有用的资源