使用jquery mobile设置表单输入元素内联

时间:2012-02-07 20:30:54

标签: html css jquery-mobile

我创建了一个jquery移动表单,但每个元素都在一个新行中。我会将出生地后的PR字段放在一个独特的行中,单选按钮男/女与出生日期在同一行。我能怎么做?我甚至尝试使用网格列布局,但没有工作。这是我自己的代码:

<div data-role = "content">
        <form action = "?" method="post" name="form" id = "form">
            <fieldset>

            <div data-role = "fieldcontain" class = "ui-hide-label">
                <label for="name">Name</label>
                <input type="text" name="name" id="name" value="" placeholder="Name" />
            </div>

            <div data-role ="fieldcontain" class= "ui-hide-label">
                <label for="surname">Surname</label>
                <input type="text" name="surname" id="surname" value="" placeholder="Surname"/>
            </div>

            <div data-role ="fieldcontain" class= "ui-hide-label">
                <label for="address">Address</label>
                <input type="text" name="address" id="address" value="" placeholder="Address"/>
            </div>

                <div data-role="fieldcontain" class = "ui-hide-label">
                    <label for="birth-place">Birth Place</label>
                    <input type="text" name="birth-place" id="birth_place" value="" placeholder="Birth Place" />
                </div>
                <div data-role = "fieldcontain" class="ui-hide-label">
                    <label for="province">Province</label>
                    <input type="text" name="province" id="province" value="" placeholder="PR" />
                </div>

                <div data-role="fieldcontain" class="ui-hide-label">
                    <label for"date">Birth Date</label>
                    <input type="datetime" name="dt" id="dt" value="" placeholder="Birth Date" />
                </div>

                <div data-role="fieldcontain">
                    <fieldset data-role="controlgroup" data-type="horizontal">
                        <input type="radio" name="radio-choice-1" id="radio-choice-1" value="male" />
                        <label for="radio-choice-1">Male</label>
                        <input type="radio" name="radio-choice-1" id="radio-choice-2" value="female"  />
                        <label for="radio-choice-2">Female</label>
                    </fieldset>
                </div>

                <div data-role="fieldcontain" data-type="horizontal">
                    <label for="select-choice-0"></label>
                    <select name="select" id="select">
                        <option value="politrauma">Politrauma</option>
                        <option value="cardiologico">Cardiologico</option>
                        <option value="neurologico">Neurologico</option>
                    </select>
                </div>

                </div>
            </fieldset>
        </form>
    </div>

1 个答案:

答案 0 :(得分:4)

两列的网格布局工作正常。以下是修改后的代码。

<form action = "?" method="post" name="form" id = "form">
        <fieldset>

        <div data-role = "fieldcontain" class = "ui-hide-label">
            <label for="name">Name</label>
            <input type="text" name="name" id="name" value="" placeholder="Name" />
        </div>

        <div data-role ="fieldcontain" class= "ui-hide-label">
            <label for="surname">Surname</label>
            <input type="text" name="surname" id="surname" value="" placeholder="Surname"/>
        </div>

        <div data-role ="fieldcontain" class= "ui-hide-label">
            <label for="address">Address</label>
            <input type="text" name="address" id="address" value="" placeholder="Address"/>
        </div>

        <div class="ui-grid-a">
            <div class="ui-block-a">
                <div data-role="fieldcontain" class = "ui-hide-label">
                    <label for="birth-place">Birth Place</label>
                    <input type="text" name="birth-place" id="birth_place" value="" placeholder="Birth Place" />
                </div>
            </div>
            <div class="ui-block-b" style="width:48.5%">
                <div data-role = "fieldcontain" class="ui-hide-label">
                    <label for="province">Province</label>
                    <input type="text" name="province" id="province" value="" placeholder="PR" />
                </div>
            </div>                
        </div>

        <div class="ui-grid-a">
            <div class="ui-block-a">
                <div data-role="fieldcontain" class="ui-hide-label">
                    <label for"date">Birth Date</label>
                    <input type="datetime" name="dt" id="dt" value="" placeholder="Birth Date" />
                </div>
            </div>
            <div class="ui-block-b">
                <div data-role="fieldcontain">
                    <fieldset data-role="controlgroup" data-type="horizontal">
                        <input type="radio" name="radio-choice-1" id="radio-choice-1" value="male" />
                        <label for="radio-choice-1">Male</label>
                        <input type="radio" name="radio-choice-1" id="radio-choice-2" value="female"  />
                        <label for="radio-choice-2">Female</label>
                    </fieldset>
                </div>
            </div>                
        </div>              

            <div data-role="fieldcontain" data-type="horizontal">
                <label for="select-choice-0"></label>
                <select name="select" id="select">
                    <option value="politrauma">Politrauma</option>
                    <option value="cardiologico">Cardiologico</option>
                    <option value="neurologico">Neurologico</option>
                </select>
            </div>

            </div>
        </fieldset>
    </form>