1

在涉及 CSS 和样式表时,我对 formtastic 完全陌生,而且非常缺乏经验。

我正在尝试重新排列布局,使其看起来像这张图片的底部: http://img242.imageshack.us/img242/3971/layoutiy.jpg 如您所见,我设法使下拉菜单很好地对齐,但费用/顾问时间却没有。

这是我的 .erb 文件;

<div id="defaults">
    <% semantic_form_for <more stuff goes here> %>
    ......
    <div id="customer-details">
        <%= form.input :fee %>
        <%= form.input :consultant_hours %>

        <%= form.input :automatic_prolonging, :as => :radio, :collection => [[("Yes"), "true" ]] + [[("No"), 'false']], :wrapper_html => { :class => "compact" } %>
        <%= form.input :customer_segment, :as => :radio, :collection => [[("Industry"), "Industry" ]] +[[("Bank/Finance"), "Bank/Finance" ]] + [[("Products/Services"), 'Products/Services']]+ [[("Organization"), 'Organization']]+[[("Other"), 'Other']], :wrapper_html => { :class => "compact" } %>
    </div>
    <% end %>

我编辑了我的 formtastic_changes.css 文件如下:

#customer-details li{
    clear: none;
    float: left;
    padding: 0;
    height: 60px;
    margin-right: 40px;
}

#customer-details .compact ol li, #social-post-defaults .compact ol li,
#customer-details .compact ol, #social-post-defaults .compact ol {
    width: 220px !important; 
    height: auto !important;
}

#customer-details .compactSelect, #social-post-defaults .compactSelect {
    width: 160px !important;
}

#customer-details .compactSelect ol, #social-post-defaults .compactSelect ol {
    width: 220px !important;
}

#customer-details .compactSelect .field, 
#social-post-defaults .compactSelect .field {
    width: 146px !important;
}

#customer-details .compactSelect ol li, 
#social-post-defaults .compactSelect ol li {
    width: 160px;
    height: auto !important;
    white-space: nowrap;
}

#customer-details .string input {
    width: 285px;
    margin: 2px 0 5px;
    padding: 2px;
    font-size: 13px;
}

这就是问题所在。无论我改变多少宽度属性,都没有改变。如果我删除“.string”,宽度更改工作,但字段仍然不会彼此相邻对齐,而是在彼此上方/下方对齐。

我已经观看了有关 railcasts 的两个 Formtastic 教程并查看了 formtastic Rdoc,但我似乎仍然无法解决这个问题。

任何人都可以将我推向正确的方向吗?感谢您的帮助。

4

1 回答 1

2

@Emil:试试

#customer-details input {
    float: left;
    font-size: 13px;
    margin: 2px 0 5px;
    padding: 2px;
    width: 285px;
}
于 2010-11-16T14:43:13.153 回答