操纵 jQuery Mobile 页脚的位置
我有一个问题已被查看,但没有对此问题的答案或评论,所以我想我应该尝试简化我的问题。对于那些对我的整体问题感到好奇的人,请参阅链接:jQuery Mobile 中的持久标头
无论如何,我的问题是如何强制 JQM 页脚位于顶部而不是底部?这是 JQM 页脚的代码。它在页面转换中保持良好,但它位于页面的底部,我需要它在头部:
<div data-role="footer" data-position="fixed" data-id="navBar" id="navigationBar">
<img src="images/bgheader.png" />
</div>
我已经在考虑用 Sencha 重建它,但由于我明天有最后期限,我认为这不是可能的。这个持久标头是目前唯一缺少的东西(当页面由于某种原因转换时,JQM 标头不会保留)。
I have a question that has been viewed, but with no answers or comments on the matter, so I thought I'd try to simplify my question. For those curious about my overall issue, please see the link: Persistent header in jQuery Mobile
Anyways, my question is how can I force the JQM footer to be at the top instead of the bottom? Here's the code for the JQM footer. It persists fine across page transitions, but it is at the foot of the page and I need it at the head:
<div data-role="footer" data-position="fixed" data-id="navBar" id="navigationBar">
<img src="images/bgheader.png" />
</div>
I'm already looking into rebuilding it with Sencha, but since I have a deadline of tomorrow, I don't think that's possible. This persistent header is the only thing missing at the moment (JQM headers don't stay when the page transitions for some reason).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我有类似的问题。
就我而言,我希望页脚完全位于页面底部,因此我将页脚 div 包装到一个新的 div 中,放置在我需要的位置。
让代码说明一切:
然后
通过这种方式,您可以自由移动页脚包装器(与其他普通 div 一样,不受 jQuery Mobile 的 css 管理),例如,在您的情况下,您必须删除
bottom: 0px ;
属性并在top: -header's height-px;
中更改它,希望有帮助!
I had a similar issue.
In my case I wanted the footer stay exactly in the bottom of the page so I wrapped the footer div into a new div positioned where I need to.
Let the code speak for itself:
then
In this way you can move the footer wrapper freely (as every other normal div, not managed by jQuery Mobile's css) for example, in your case, you have to delete the
bottom: 0px;
attribute and change it intop: -header's height-px;
I hope it helps!
在文档中指出:
所以这同样适用于标题。不要尝试移动页脚,而是将页眉固定为持久的。
我在此处找到了一个示例,在使页脚和页眉持久化下。
In the docs it is stated:
So the same applies to the header. Instead of trying to move the footer, fix the header to be persistent.
I found an example here, under Making footers and headers persistent.
我认为这是不可能的,至少通过使用 JQM 页脚是不可能的。该文档没有透露您可以设置的任何会更改位置的属性,并且 JQM 正在主动管理
本身的位置。它直接将其修改为
style='top: -1304px'
之类的内容,并且每次滚动或更改屏幕时它都会更改值。所以,你甚至不能通过修改 CSS 来改变它。 JQM 永远会赢,因为它修改了内联样式。我认为您陷入困境的主要原因是 JQM 为您提供了假定的页面布局。您的常用导航控件应该位于屏幕底部,屏幕顶部应在每个页面上显示不同的内容,可能还带有后退按钮。这就是他们的设想,到目前为止,他们还没有开发出任何其他布局的可能性。
您也许可以通过采取完全不同的方法来实现您的目标,但我们首先需要对您的目标有一个更清晰的定义。
祝你好运。希望您的利益相关者喜欢将固定元素放在屏幕底部。
I don't think this is possible, at least not by using the JQM footer. The documentation doesn't reveal any attributes you can set which would change the position and JQM is actively managing the position on the
<div>
itself. It's modifying it directly as something likestyle='top: -1304px'
and it changes values every time you scroll or change screens. So, you can't even change it by modifying the CSS. JQM will always win, since it's modifying the inline styles.I think the main reason that you're stuck is that JQM is giving you an assumed page layout. Your common navigation controls are supposed to be at the bottom of the screen and the top of the screen should display something different on every page, with possibly a back button. That's how they envisioned it and, thus far, they haven't developed any other layout possibilities.
You may be able to accomplish your goal by taking an entirely different approach, but we'd need a clearer definition of your goal first.
Best of luck to you. Hopefully, your stakeholders like having the fixed elements at the bottom of the screen.
将以下 css 添加到您的页面或 css 文件的底部。
请注意,我尚未在移动设备上测试此代码。
Add the following css to your page or to the bottom of the css file.
Please note I have not tested this code on mobile devices..
这对我有用。
在每个页面 div 内,包含一个具有数据角色“页脚”的 div,如下所示。
在我的应用程序中,内联样式可以防止导航栏在内容添加到页面中间时被按下,使用如下内容:
不幸的是,导航栏必须在每个页面 div 中重复。
This worked for me.
Inside each page div, include a div with data-role "footer", as below.
The inline style, in my app, prevented the navbar from being pushed down when content is added to the middle of the page, using something like this:
It's unfortunate that the navbar must be repeated in each page div.
我在每个 data-role="page":
css:
内部都取得了一些成功,实际上我也能够有第二个“真正的”页脚,固定在页面底部。我已经在我的 HTC Amaze 和 iOS 模拟器上对此进行了测试。
我很想知道这是否适用于其他设备。
I've had some success with this, inside of each data-role="page":
css:
And I've actually been able to have a second "real" footer, as well, fixed to the bottom of the page. I've tested this on my HTC Amaze, and the iOS simulator.
I would be interested to know if this is working on other devices.