CSS表单样式有助于内联dt / dd元素

时间:2012-03-01 16:56:08

标签: html css

我需要帮助设置搜索(数据过滤器)表单的样式。我想要的是将标签文本右对齐,并在标签右侧显示文本框。但我想要从/到标签&开头的文字&结束日期全部在同一行,包括搜索按钮。我怎样才能实现这种效果?

参见附件示例线框,search mockup

我正在使用http://gawibowo.com/theme/adminique/forms.html中的表单样式。我可以制作“选择项目”标签/输入& '从'标签/输入显示正确,它显示'To'标签/输入和按钮在同一行显示'我'遇到麻烦。

当前的HTML

<form accept-charset="UTF-8" action="http://localhost:3000/reports/report/realtime-transaction-activity" class="filter" data-remote="true" id="realtime_transaction_activity_form" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="?"><input name="authenticity_token" type="hidden" value="GTpmMlHkQSkoRdBgjcVYQGJOyf6UX9brW5yzVY/MrHY="></div>
 <div class="group">
    <dl class="inline">
      <dt>
        <label class="label" for="terminals">Terminals:</label>
      </dt>
      <dd>
        <select id="terminals" multiple="multiple" name="terminals[]" width="400" style="display: none; "><option value="3417">Midland U Cafeteria - A005</option>
        <option value="3686">Midland UBookstore - A201</option></select><button type="button" class="ui-multiselect ui-widget ui-state-default ui-corner-all" aria-haspopup="true" tabindex="0" style="width: 225px; "><span class="ui-icon ui-icon-triangle-2-n-s"></span><span>Select options</span></button>
      </dd>
      <dt>
        <label class="label" for="from">From:</label>
      </dt>
      <dd>
        <input class="text_field hasDatepicker" id="from" name="from" required="required" type="text">
        <div class="to">
          <label class="label" for="to">To:</label>
          <input class="text_field hasDatepicker" id="to" name="to" required="required" type="text">
          <button class="button small" data-disable-with="Please wait..." name="button" type="submit">Search</button>
          <img alt="Ajax-loader" id="ajax_loader" src="/assets/ajax-loader.gif" style="display:none">
        </div>
      </dd>

    </dl>
    <br>
  </div>
</form>

css(表单/ dl / dt / dd元素)

form dt {
margin-bottom: 2px;
}
form dd {
    margin-bottom: 15px;
}
form dt label {
    cursor: pointer;
    font: 11px Tahoma, sans-serif;
    font-weight: bold;
    color: #555;
}

form p {
    clear: left;
    margin-bottom: 0;
    padding: 5px 0;
    width: 100%;
}
form p label {
    display: block;
    float: left;
    cursor: pointer;
    font: 11px Tahoma, sans-serif;
    font-weight: bold;
    color: #555;
    width: 100px;
    vertical-align: middle;
    padding: 5px;
    text-align: right;
    margin-right: 10px;
}
form p small {
    display: block;
    margin: 0 10px 0 120px;
    font-size: 10px;
    color: #aaa;
}

form dl.inline dt {
    clear: both;
    width: 25%;
    float: left;
    text-align: right;
}
form dl.inline dt label {
    margin-right: 12px;
}
form dl.inline dd {
    float: left;
    width: 74%;
    margin: 0 0 15px;
}

1 个答案:

答案 0 :(得分:0)

尝试浮动dd中的其他元素。

form dd input, form dd label, form dd button {float:left; }​

fiddle