您好,我想知道如何使用表单的样式化组件更改CSS。语义输入

我需要在胡佛上这样的事情:

reactjs - 样式化的组件语义工具包(表格输入)-LMLPHP

但是我不能同时更改输入的背景色和边框颜色

and hover:
export const FormCustom = styled(Form)`
&&& {
    background: #000;
}
`
export const FormInput = styled(Form.Input)`
&&& {
    color: red;
    background: transparent;
}
`


尝试但无济于事

export const FormInput = styled(Form.Input)`
&&& {
    color: red;
    background: transparent;
}
`


我的表格:

<FormCustom size='large'>
        <Segment basic>
          <FormInput fluid icon='user' iconPosition='left' placeholder='E-mail address' />
          <FormInput
            fluid
            icon='lock'
            iconPosition='left'
            placeholder='Password'
            type='password'
          />

          <Button color='teal' fluid size='large'>
            Login
          </Button>
        </Segment>
      </FormCustom>


代码:https://codesandbox.io/s/fast-morning-hq5zq

最佳答案

请参考以下示例链接:codesandbox

我已经更新了CSS属性,并使用样式组件对表单控件的悬停产生了影响。目前,我只是根据您的图像共享设置颜色代码,因此您可以将其更改为所需的颜色代码。

现在,在悬停输入控件和图标颜色上,都可以根据您的要求进行更改。

您需要如下更新样式化的组件

export const FormInput = styled(Form.Input)`
  border: 2px solid red;
  border-radius: 0.28571429rem;
  background: transparent;
  -webkit-box-shadow: 0px 0em 0em 0em rgba(34, 36, 38, 0.35) inset;
  box-shadow: 0px 0em 0em 0em rgba(34, 36, 38, 0.35) inset;
  input {
     border: none !important;
  }
  &:hover {
    border: 2px solid #7159c1;
    background: #333;
    i {
      color: #7159c1;
    }
  }
  &:focus {
    color: #000;
    border-color: #000;
    border-radius: 0.28571429rem;
    background: transparent;
    -webkit-box-shadow: 0px 0em 0em 0em rgba(34, 36, 38, 0.35) inset;
    box-shadow: 0px 0em 0em 0em rgba(34, 36, 38, 0.35) inset;
  }
`;

10-08 03:12