has*_*ghe 3 css reactjs material-ui
如何对齐 Material UI 输入文本的文本?以下似乎不起作用。我使用的是 1.x 版
import {Input} from 'material-ui';
//didn't work
<Input
className="max-w-128 inline-block"
style = {{textAlign: 'center'}}
id="input-quantity"
inputStyle={{ textAlign: 'center' }}
//tried hintStyle as suggested in a bug
hintStyle={{ width: '600px', textAlign: 'center' }}
value={this.state.currentRecord.quantity}
onChange={this.handleCurrentRecordTextChange('quantity')}
/>
Run Code Online (Sandbox Code Playgroud)
你只需要使用(覆盖样式):
classes={{
input: classes.inputCenter
}}
Run Code Online (Sandbox Code Playgroud)
样式应该是:
const styles = theme => ({
inputCenter: {
textAlign: "center",
color: "red"
}
});
Run Code Online (Sandbox Code Playgroud)
从这里浏览文档:https : //material-ui.com/api/input/#css-api
这是一个工作示例:https : //codesandbox.io/s/n9nr9x8xo0
希望这会帮助你。
小智 5
请用
<Typography align="centre|right" />
Run Code Online (Sandbox Code Playgroud)
如果您已经设置了特定字体,则将上述解决方案与 withStyle HOC 一起使用
| 归档时间: |
|
| 查看次数: |
13096 次 |
| 最近记录: |