som*_*pan 7 css textfield reactjs material-ui
前 10% 为一种背景颜色,另外 90% 为另一种背景颜色。
<TextField
className={classes.root}
type="text"
placeholder="username"
variant="outlined"
style={{borderRadius:'50',
backgroundColor: "white"
}}
InputProps={{
startAdornment: (
<InputAdornment position="start">
<PersonIcon />
</InputAdornment>
)
}}
/>
Run Code Online (Sandbox Code Playgroud)
我在下面附上演示文本字段
这是您如何覆盖以InputAdornment在屏幕截图中实现相同效果的方法。请注意,input旁边的InputAdornment已box-sizing设置为content-box,因此它不像在装饰中设置heightto那么简单。100%我必须在此处复制填充代码以确保装饰的高度与以下的高度相同OutlinedInput:
<TextField
placeholder="With normal TextField"
sx={{
"& .MuiOutlinedInput-root": {
paddingLeft: 0
}
}}
InputProps={{
startAdornment: (
<InputAdornment
sx={{
padding: "27.5px 14px",
backgroundColor: (theme) => theme.palette.divider,
borderTopLeftRadius: (theme) =>
theme.shape.borderRadius + "px",
borderBottomLeftRadius: (theme) =>
theme.shape.borderRadius + "px"
}}
position="start"
>
kg
</InputAdornment>
)
}}
Run Code Online (Sandbox Code Playgroud)
V5
V4
| 归档时间: |
|
| 查看次数: |
10679 次 |
| 最近记录: |