代码之家  ›  专栏  ›  技术社区  ›  James Delaney

无法在react semantic中重新指定标签的fontSize

  •  1
  • James Delaney  · 技术社区  · 6 年前

    如果我有表单输入哪个标签-->我不能缩小标签的尺寸。

    在此示例中,将不应用fontSize:

    <Form.Input label="Username" style={{fontSize: '10px'}}  />
    

    有人知道如何解决这个问题吗?

    3 回复  |  直到 5 年前
        1
  •  1
  •   Chetan Singhal    6 年前

    我认为您需要像下面这样拆分标签和输入,这样才能使用内联样式:

    <Form.Input label='Enter Password' type='password' />
    vs
    
    <Form.Field>
      <label style={{fontSize: '10px'}}>Enter Password</label>
      <Input type='password' style={{fontSize: '10px'}} />
    </Form.Field>
    
        2
  •  2
  •   Chetan Singhal    6 年前

    你能用这个简单的方法在任何组件上应用css吗。

    .inputCls {
      font-size: 10px !important;
    }
    <Form.Input label="Username" className="inputCls"  />
        3
  •  2
  •   Asaf    5 年前

    还有一种更干净的方法,这也在 official docs .

    <Form.Input label="Username" style={{fontSize: '10px'}}  />
    

    将具有样式首选项的对象传递到标签属性,如下所示:

    <Form.Input label={{ children: "Username", style:{ fontSize: '10px' } }} />
    
        4
  •  1
  •   Sagiv b.g    6 年前

    如果你不能创建外部 CSS Label 的样式 Form.Input

    <Form.Field>
      <label>Enter text</label>
      <Input type='text' />
    </Form.Field>
    

    标签

    <Form.Field>
      <label style={{fontSize: '15px'}}>Enter text</label>
      <Input type='text' />
    </Form.Field>
    

    看到了吗 docs

        5
  •  0
  •   Chris Perry    4 年前

    下面介绍如何自定义语义ui输入字体大小,而无需创建自定义类或使用!很重要。

    1. input.css )并添加以下规则:
    .ui.input > input {
      font-size: 10px;
    }
    
    1. 将css文件导入根组件。
    import './input.css'