如何用CSS更简化simple_form输入字段?

时间:2013-08-23 22:29:35

标签: css ruby-on-rails simple-form

这可能是一个愚蠢的问题。我们正在努力使simple_form输入字段更宽。这是github上发布的simple_form css:

/* ----- SimpleForm Styles ----- */

.simple_form div.input {
  margin-bottom: 10px;
  clear: both; /* Required for Webkit, but not for Gecko */
}

.simple_form label {
  float: left;
  width: 100px;
  text-align: right;
  margin: 2px 10px;
}

div.boolean, .simple_form input[type='submit'] {
  margin-left: 120px;
}

div.boolean label, label.collection_radio_buttons {
  float: none;
  margin: 0;
}

label.collection_radio_buttons {
  margin-right: 10px;
  vertical-align: -2px;
  margin-left: 2px;
}

.field_with_errors {
  background-color: #ff3333;
}

.simple_form .error {
  clear: left;
  color: black;
  display: block;
  margin-left: 120px;
}

.simple_form .hint {
  clear: left;
  margin-left: 120px;
  color: #555;
  display: block;
  font-style: italic;
}

input.radio {
  margin-right: 5px;
  vertical-align: -3px;
}

input.check_boxes {
  margin-left: 3px;
  vertical-align: -3px;
}

label.collection_check_boxes {
  float: none;
  margin: 0;
  vertical-align: -2px;
  margin-left: 2px;
}

Or in SASS format:

/* ----- SimpleForm Styles ----- */

.simple_form
  div.input
    margin-bottom: 10px
    clear: both

  label
    float: left
    width: 100px
    text-align: right
    margin: 2px 10px

  .error
    clear: left
    color: black
    display: block
    margin-left: 120px

  .hint
    clear: left
    margin-left: 120px
    color: #555
    display: block
    font-style: italic

div.boolean, .simple_form input[type='submit']
  margin-left: 120px

div.boolean label, label.collection_radio_buttons
  float: none
  margin: 0

label.collection_radio_buttons
  margin-right: 10px
  vertical-align: -2px
  margin-left: 2px

.field_with_errors
  background-color: #ff3333

input.radio
  margin-right: 5px
  vertical-align: -3px

input.check_boxes
  margin-left: 3px
  vertical-align: -3px

label.collection_check_boxes
  float: none
  margin: 0
  vertical-align: -2px
  margin-left: 2px

我们在div input {}中尝试了一些选项,但字段宽度没有变化。不确定哪个部分用于输入字段的布局。如何修改上面的CSS,使输入字段更宽?感谢帮助。

1 个答案:

答案 0 :(得分:1)

添加:

width: 600px:

要:

.simple_form div.input { }

以600px为例。谷歌“输入.width CSS”了解更多信息。

如果您只想将其应用于文本字段,请使用input [type = text]