Question

I have a dropdown form, whose width is currently constrained by the width of the link activating the dropdown:

the problem

I want the form to extend as far as needed to put all form elements on one line. How can I do that?

Current HTML code:

<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">&dash;</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">&dash;</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

Also, for whatever reason, clicking on the form makes it disappear right now. This doesn't happen on the actual webpage I was working with, only on the JSFiddle page. I've bypassed this issue by pressing tab for now.

Was it helpful?

Solution

h1 div#date-filter-dropdown ul.dropdown-menu {
    white-space:nowrap;
    min-width: 10px;
}

OTHER TIPS

Try these:

<ul class="dropdown-menu" id="ddown" role="menu">  //added a id for the dropdown

and add these 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.

http://jsfiddle.net/Gz3JD/1/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top