css - 禁用时更改文本文件的颜色
问题描述
我想在禁用时更改文本文件的颜色。我为启用和禁用编写此代码。启用效果很好。
const StyledTextField = styled(({ dir, ...other }) => <TextField {...other} />)`
label.focused {
color: green;
}
.MuiOutlinedInput-root {
direction: ${props => (props.dir ? props.dir : "rtl")};
fieldset {
border-color: white;
background-color: rgba(2, 37, 67, 0.5);
}
&:hover fieldset {
border-color: #87ceeb;
}
&.Mui-focused fieldset {
border-color: rgba(0, 51, 96, 1);
}
fieldset {
border-color: white;
background-color: rgba(2, 37, 67, 0.5);
}
}
}
.MuiOutlinedInput-root.Mui-disabled {
direction: ${props => (props.dir ? props.dir : "rtl")};
fieldset {
border-color: black;
background-color:black;
}
&:hover fieldset {
border-color: black;
}
&.Mui-focused fieldset {
border-color: black;
}
fieldset {
border-color: black;
background-color:black;
}
}
${props =>
props.center &&
`.MuiOutlinedInput-input {
text-align: center;
}`}
`;
export default StyledTextField;
这是我的文本文件:
<MyTextField
id={props.id}
name={props.id}
className={props.classes.textField}
value={props.value}
onChange={props.onChange}
margin="dense"
variant="outlined"
type={props.type ? props.type : "text"}
error={props.error}
fullWidth={props.width ? false : true}
style={props.width ? { width: props.width } : {}}
dir={props.dir}
inputProps={{ readOnly: props.disable }}
label={props.message}
disable={props.disable}
/>
我像这样使用它:
<InputRow
id="qwe"
value={min_quality_threshold}
onChange={this.handleChange}
classes={classes}
disable={true }
/>
在 inputRow 中,我将 disable 设置为 true。这样我就被禁用了,然后它应该具有禁用根的样式。但它没有改变。
解决方案
如果您在 Input 上设置 disabled 属性,一些 CSS 应该这样做
fieldset:disabled {
border-color: darkgrey;
background-color: grey;
}
推荐阅读
- python - 使用 tkinter 切换按钮文本
- javascript - 按键从 JavaScript 对象中提取值
- php - 在 WooCommerce 帐户上格式化帐单电话号码以在代码和号码之间添加空格
- flutter - SliverList 未按预期更新
- python - tkinter 中的 Label 和 ttk.Label 有什么区别
- android - 如何通过代码更改扩展浮动操作按钮图标?
- python - 如何在Django中将对象从一个视图传递到另一个视图?
- javascript - 向 cytoscape.js 中的某些节点添加 diffrenet href
- android - Android java.lang.UnsatisfiedLinkError:找不到要加载的 DSO
- c# - 将 Serilog 与 Microsoft.Extensions.Logging.ILogger 一起使用