简体   繁体   中英

Fixed header navbar issue with jQuery Mobile

I'm trying to implement a fixed navbar in my app and I'm have an issue where the navbar doesn't show up. It seems to appear collapsed, see the following image for reference:

在此处输入图片说明

It is supposed to look like this:

在此处输入图片说明

Here is the related code I am using:

<div data-role="header" data-id="header" data-position="fixed">
            <div data-role="navbar">
                <ul>
                    <li><a href="index.html" data-role="button" data-icon="b" data-inline="true" data-iconpos="notext" class="ui-btn-right"></a></li>
                    <li><a href="index.html" data-role="button" data-icon="star" data-inline="true" data-iconpos="notext" class="ui-btn-right"></a></li>
                    <li><a href="index.html" data-role="button" data-icon="grid" data-inline="true" data-iconpos="notext" class="ui-btn-right"></a></li>
                    <li><a href="index.html" data-role="button" data-icon="search" data-inline="true" data-iconpos="notext" class="ui-btn-right"></a></li>
                </ul>
            </div><!-- /navbar -->
</div><!-- /header -->

I am able to successfully achieve the 2nd image by implementing the navbar outside of the header block, but I then can't set it to fixed position. I'm certain it isn't any issues with my CSS as I'm using the default theme minus a few color tweaks. Any suggestions?

-- UPDATE --

As requested here is a quick and dirty implementation on jsfiddle .

I removed data-role="button" and class="ui-btn-right" and it made a proper navbar. Links in a navbar are automatically styled as buttons and evenly spaced. Not sure if data-inline="true" is necessary but I left it in. In the navbar I use I don't use it though.

<div data-role="header" data-id="header" data-position="fixed">
            <div data-role="navbar">
                <ul>
                    <li><a href="index.html"  data-icon="b" data-inline="true" data-iconpos="notext"></a></li>
                    <li><a href="index.html"  data-icon="star" data-inline="true" data-iconpos="notext"></a></li>
                    <li><a href="index.html" data-icon="grid" data-inline="true" data-iconpos="notext"></a></li>
                    <li><a href="index.html" data-icon="search" data-inline="true" data-iconpos="notext"></a></li>
                </ul>
            </div><!-- /navbar -->
</div><!-- /header -->​
<div data-role="header">        
    <div data-role="navbar" data-iconpos="bottom">
        <ul>
            <li ><a  data-icon="search" href="#" href="a.html" >One</a></li>
            <li><a  data-icon="search" href="#" href="a.html" >Two</a></li>
            <li><a  data-icon="search" href="#" href="a.html" >Three</a></li>
        </ul>
    </div><!-- /navbar -->
</div><!-- /footer -->​

This code works pretty well. http://jsfiddle.net/K6GMG/4/ i dont see any use of using button for a tag since they are already buttons.

but some how when i add this class="ui-btn-right" is breaking the code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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