【问题标题】:My CSS style sheet is having no impact on my React component我的 CSS 样式表对我的 React 组件没有影响
【发布时间】:2015-11-29 16:05:23
【问题描述】:

我正在尝试使用 CSS 样式表设置我的 React 组件的样式。我想更改边距以更好地分隔我的元素,但我的 div 类似乎被破坏了,或者我没有正确理解这个概念。这是我当前代码的输出:

我想在帐户名称输入框和文本之间添加空格。

这是我的反应:

renderGetAccountName: function renderGetAccountName() {
return (
  <Dialog onClose={this.onGetAccountNameClose} height={300}>
    <h1 style={dialogHeaderStyle}>
      NAME YOUR ACCOUNT
    </h1>

    <span style={errorMessage}>
      It is time to name your new account! Please enter your choice below, and click "OK" when you are finished.
    </span>


    <div classname="nameInput">
      <form id="frm1" action="form_action.asp">
        ACCOUNT NAME: <input type="text" name="new-account-name"></input>
      </form>
    </div>

    <Button type='button submit' style={submitStyle}>
      OK
    </Button>
    <span>
      <button type="button">Cancel</button>
    </span>

  </Dialog>
);
  }

这是我的 CSS:

.gone
  display: none

.contact
.controls
  .dropdown-menu
    li
      border-top: 1px solid #B3B3B3
      cursor: pointer
      padding-top: 8 px
      text-transform: capitalize
      text-align: center
      height: 44 px


      &:hover
         background-color: #EEE

.nameInput
    margin-top: 50px
    margin-left: 50px

【问题讨论】:

  • className 而不是 classname
  • 我觉得自己像个白痴,你们是最棒的,谢谢!

标签: javascript html css reactjs


【解决方案1】:

您必须使用className,而不是使用classname

【讨论】:

    【解决方案2】:

    使用className={"nameInput"}。属性为驼峰式。

    【讨论】:

      猜你喜欢
      • 2020-12-26
      • 2019-08-01
      • 2018-05-01
      • 2020-10-04
      • 2021-12-08
      • 1970-01-01
      • 1970-01-01
      • 2022-01-17
      • 1970-01-01
      相关资源
      最近更新 更多