简体   繁体   English

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

[英]CSS form styling help inline dt/dd elements

I need help styling a search (data filter) form. 我需要样式化搜索(数据过滤器)表单的帮助。 What I want is to have label text right aligned, and text boxes to the right of the labels. 我想要的是使标签文本正确对齐,并在标签右侧添加文本框。 But I want the from / to labels & text for the begin & end date all on the same line, including the search button. 但是我希望开始和结束日期的从/到标签和文本都在同一行上,包括搜索按钮。 How can I accomplish this affect? 我如何才能实现这种影响?

See attached sample wireframe, 请参阅随附的示例线框, 搜索样机

I am using the form style from http://gawibowo.com/theme/adminique/forms.html . 我正在使用http://gawibowo.com/theme/adminique/forms.html中的表单样式。 I'm able to make the 'Select Items' label / input & 'From' label / input display correctly, it is displaying the 'To' label / input and button on same line as 'From' that I'm having trouble with. 我能够正确显示“选择项目”标签/输入和“发件人”标签/输入,它在与“发件人”相同的行上显示“收件人”标签/输入和按钮。

Current html 当前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 (for form/dl/dt/dd elements) CSS(用于form / 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;
}

Try floating the other elements that are inside the dd. 尝试浮动dd内的其他元素。

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

fiddle 小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM