jquery mobile改变navibar的宽度

发布于 2025-01-05 04:50:27 字数 1597 浏览 3 评论 0原文

如何更改 jQuery Mobile 中导航栏的宽度,如 this

在 m.IKEA 中,它是 make:

<div data-role="header" id="ikea-homeheader" data-backbtn="false">
    <div id="ikea-navbar" data-role="headerbar" data-moreListId="#ikea-more-list">
        <ul>            
            <li class="ikea-navbar-item "><a href="/se/sv/" >Hem</a></li>
            <li class="ikea-navbar-item "><a href="/se/sv/catalog/functional/" >Sortiment</a></li>
            <li class="ikea-navbar-item "><a href="/se/sv/shoppinglist/" rel="nofollow">Inkopslista</a></li>
            <li class="ikea-navbar-item ikea-navbar-item-active"><a href="/se/sv/stores/" >Varuhus</a></li>

            <li class="ui-headerbar-more-item" data-role="headerbar-more-item"><a data-role="popupbutton" data-popup-content="more-item-popup" ><div class="ikea-navbar-more-image"></div></a></li>
        </ul>
    </div>
</div>


<div data-role="popup" id="more-item-popup">
    <ul data-role="listview" data-theme="d" id="ikea-more-list">
    </ul>
    <div data-role="popup-cancel-button">
        <div data-role="button" data-theme="c">Cancel</div>

    </div>
</div>

但我不明白它是如何工作的。

在我的 jQuery mobile 1.0.1 中,它不起作用...

什么是 data-role="headerbar"data-moreListIddata-role="标题栏更多项目”

How to change navbar in jQuery Mobile from width like this?

In m.IKEA it's make:

<div data-role="header" id="ikea-homeheader" data-backbtn="false">
    <div id="ikea-navbar" data-role="headerbar" data-moreListId="#ikea-more-list">
        <ul>            
            <li class="ikea-navbar-item "><a href="/se/sv/" >Hem</a></li>
            <li class="ikea-navbar-item "><a href="/se/sv/catalog/functional/" >Sortiment</a></li>
            <li class="ikea-navbar-item "><a href="/se/sv/shoppinglist/" rel="nofollow">Inkopslista</a></li>
            <li class="ikea-navbar-item ikea-navbar-item-active"><a href="/se/sv/stores/" >Varuhus</a></li>

            <li class="ui-headerbar-more-item" data-role="headerbar-more-item"><a data-role="popupbutton" data-popup-content="more-item-popup" ><div class="ikea-navbar-more-image"></div></a></li>
        </ul>
    </div>
</div>


<div data-role="popup" id="more-item-popup">
    <ul data-role="listview" data-theme="d" id="ikea-more-list">
    </ul>
    <div data-role="popup-cancel-button">
        <div data-role="button" data-theme="c">Cancel</div>

    </div>
</div>

But how it's work I don't understand.

In my jQuery mobile 1.0.1 It's don't work ...

What's data-role="headerbar", data-moreListId, data-role="headerbar-more-item" ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜还是长夜 2025-01-12 04:50:27

如果您尝试在方向更改时刷新宽度,您可以尝试使用以下命令重新应用 jqm 样式/格式:

$("#your-jqm-page").page();

.page() 使用 jQM 标记刷新页面。您可能还必须尝试 .trigger("create") 方法,如下所述:JQuery Mobile .page() 函数导致无限循环?

至于您的其他新问题,这些 data 属性看起来像是 jqm 框架在页面已初始化。

更新

如果您尝试检测浏览器何时调整大小,请使用如下函数:

$(window).resize(function() {

  // this is whatever size you would like to make the change on, in pixels
  var minimumPreferredSize = 600;

  if ($(window).width() < minimumPreferredSize) {
     $("#Varuhus").html("...");
  }
  else
  {
     $("#Varuhus").html("Varuhus");
  }
});

此解决方案假设您的 a 标记的 id 为瓦鲁胡斯。

此解决方案是通过另一篇文章实现的: Detect when a window is resized using JavaScript ?

希望这有帮助!

If you are trying to refresh the width on orientation change, you could try reapplying jqm styling/formatting using this command:

$("#your-jqm-page").page();

.page() refreshes the page with jQM markup. You may also have to try the .trigger("create") method as discussed here: JQuery Mobile .page() function causes infinite loop?

As for your other new questions, those data attributes look like elements added by the jqm framework after the page is initialized.

UPDATE

If you are trying to detect when a browser has resized, use a function like this:

$(window).resize(function() {

  // this is whatever size you would like to make the change on, in pixels
  var minimumPreferredSize = 600;

  if ($(window).width() < minimumPreferredSize) {
     $("#Varuhus").html("...");
  }
  else
  {
     $("#Varuhus").html("Varuhus");
  }
});

This solution assumes your a tag has an id of Varuhus.

This solution was made possible by this other post: Detect when a window is resized using JavaScript ?

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文