你如何在jQuery Mobile的固定标题的右上角制作一个翻转开关?

时间:2014-07-29 06:28:50

标签: jquery-mobile jquery-mobile-flipswitch

我尝试了以下内容:

<div data-role="header" data-position="fixed" data-tap-toggle="false">
<h1>My Page</h1>
<label for="nfcSwitch" class="ui-hidden-accessible">NFC:</label>
<input data-role="flipswitch" name="nfcSwitch" id="nfcSwitch" data-on-text="NFC on" data-off-text="NFC off" type="checkbox" />
</div>

但它显示左侧的翻转开关,位于h1

下方

1 个答案:

答案 0 :(得分:1)

<强> HTML

<div data-role="header" data-position="fixed" data-tap-toggle="false">
    <h1>My Page</h1>
    <div class="switch">
        <label for="nfcSwitch" class="ui-hidden-accessible">NFC:</label>
        <input data-role="flipswitch" name="nfcSwitch" id="nfcSwitch" data-on-text="NFC on" data-off-text="NFC off" type="checkbox"/>
    </div>
</div>

<强> CSS

.switch
{
    position: absolute;
    top: 0px;
    right: 0px;
}

<强> JSFiddle