javascript - 删除来自 Material ui 的文本框的填充

标签 javascript html css reactjs material-ui

我正在尝试从文本框中删除填充,但问题是它来自 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 },

最佳答案

如果您阅读 docs您可以找到将属性应用于 native 输入元素的 inputProps(不是 InputProps)属性。如下所示,您可以传递样式属性。

<TextField
    inputProps={{
       style: {
         padding: 5
       }
    }}
/>

关于javascript - 删除来自 Material ui 的文本框的填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53419092/

相关文章:

javascript - 如何使用 PHP 使用 javascript?

javascript - 当您打开 Popover [bootstrap] 时,屏幕失去焦点并转到顶部

javascript - 鼠标悬停事件未在某些子元素上触发

html - 对齐 asp :Button above first column of the gridview below

javascript - 如何使用 jquery 更改多个 td 元素的背景颜色

javascript - 在jquery中获取当前点击的项目值

javascript - 如何对隐藏的js脚本进行逆向工程?

javascript - 如何使用 JavaScript 检查 html 元标记是否存在?

html - 无法使表头和搜索框固定在表内

Javascript onclick 函数更改元素的所有实例?