我有一个下拉表单,其宽度目前受激活下拉列表的链接宽度的限制:
我希望表单尽可能扩展到将所有表单元素放在一行上。我怎么能这样做?
当前的HTML代码:
<h1>Time Period:
<div id="date-filter-dropdown" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<span class="primary">May 2013</span></a>
<ul class="dropdown-menu" role="menu">
<li>
<form class="form-inline">
<input type="text" class="input-mini filter-time-form" id="id_filter_form_year" maxlength="4" size="4" placeholder="YYYY" />
<span class="filter-form-date-dividers">‐</span>
<input type="text" class="input-mini filter-time-form" id="id_filter_form_month" maxlength="2" size="2" placeholder="MM" />
<span class="filter-form-date-dividers">‐</span>
<input type="text" class="input-mini filter-time-form" id="id_filter_form_day" maxlength="2" size="2" placeholder="DD" />
<button type="button" class="btn btn-primary javascript-submit" id="filter-date-submit" onclick="filter_time();">Filter</button>
</form>
</li>
</ul>
</div>
</h1>
此外,无论出于何种原因,点击表单使其立即消失。这不会发生在我正在使用的实际网页上,仅在JSFiddle页面上。我现在按Tab键绕过了这个问题。
答案 0 :(得分:1)
h1 div#date-filter-dropdown ul.dropdown-menu {
white-space:nowrap;
min-width: 10px;
}
答案 1 :(得分:1)
试试这些:
<ul class="dropdown-menu" id="ddown" role="menu"> //added a id for the dropdown
并添加这些js:
var m = document.getElementById("date-filter-dropdown").offsetWidth; //get the date div width.
// alert(m);
var n = document.getElementById("ddown");
n.style.width = m+'px'; // set dropdown width.