简体   繁体   English

用于jquery移动面板的固定页脚

[英]Fixed footer for a jquery mobile Panel

I am trying to place a fixed footer on a panel in jquery mobile. 我试图在jquery mobile中的一个面板上放置一个固定的页脚。 I have tried a couple of things but nothing seems to work. 我尝试了几件事但似乎没什么用。 Tried aa div with data-role footer but that moves to the main page. 尝试使用数据角色页脚的div,但移动到主页面。 Then I created another footer div and gave it some css styling but that pushes the footer to the bottom of the panel and not at the bottom of the window. 然后我创建了另一个页脚div并给它一些css样式,但是将页脚推到面板的底部而不是窗口的底部。 One solution I can think of is a scroll event which recalculates the height of the footer on scroll but that would give a very jerky appearance to the footer. 我能想到的一个解决方案是滚动事件,它重新计算滚动页脚的高度,但这会给页脚带来非常不稳定的外观。

Here is a sample jsfiddle with both the footers. 是一个包含两个页脚的示例jsfiddle。

HTML: HTML:

<div data-role="page" id="myPage1">
<div data-role="header">
     <h1>Page 1 header</h1>
       <a href="#mypanel" class="ui-btn-right" data-icon="gear">Open Panel</a>
</div>
<div data-role="content">
     <h1>Page 1</h1>
     Hi This is the content
</div>
<div data-role="footer">
     <h1>Page 1 Footer</h1>

</div>
<div id="mypanel" data-role="panel" data-position="right" data-display="push" 
data-theme="d" data-swipe-close="true">
    <div id="panelfooter" data-theme="d" data-role="footer"
 data-position="fixed">Footer</div>
    <div id="panelFooter">Footers</div>
    <div data-role="content">hello I am a panel
        <ul>
            <li>Hi</li>
            <li>Hi</li>
            <li>Hi</li>
            <li>Hi</li>
            <li>Hi</li>
            <li>Hi</li>
            <li>Hi</li>
            <li>Hi</li>
            <li>Hi</li>
            <li>Hi</li>
            <li>Hi</li>
            <li>Hi</li>
        </ul>
    </div>
  </div>
</div>

CSS: CSS:

#panelFooter {
  position:fixed;
  left:0px;
  bottom:0px;
  height:30px;
  width:100%;
  background:#999;
}

another try: 另一个尝试:

 #mypanelfooter { position:absolute; left:0px; bottom:3px; height:auto; width:90%; padding:5%; border:none; background-color:blue; } 
 <div data-role="page" id="myPage1"> <div data-role="header"> <h1>Page 1 header</h1> <a href="#mypanel" class="ui-btn-right" data-icon="gear">Open Panel</a> </div> <div data-role="content"> <h1>Page 1</h1> Hi This is the content </div> <div data-role="footer"> <h1>Page 1 Footer</h1> </div> <div id="mypanel" data-role="panel" data-position="right" data-display="push" data-theme="d" data-swipe-close="true"> <div id="mypanelfooter"> Footer </div> <div data-role="content"> hello I am a panel <ul> <li>Hi</li><li>Hi</li> <li>Hi</li> <li>Hi</li> <li>Hi</li> <li>Hi</li> <li>Hi</li> <li>Hi</li><li>Hi</li><li>Hi</li><li>Hi</li><li>Hi</li><li>Hi</li><li>Hi</li><li>Hi</li><li>Hi</li><li>Hi</li> <li>Hi</li> </ul> </div> </div> </div> 

if your Content in the Panel isn't to big it works... 如果您在Panel中的内容不是很大,那就有效......

我的建议是更改页脚代码如下:

<div data-role="footer" data-position="fixed" style="position: absolute">

I had a similar requirement, and I managed it by using data-position:fixed attribute. 我有类似的要求,我通过使用data-position:fixed属性来管理它。 Here is the jsfiddle: 这是jsfiddle:

<div data-role="footer" data-position="fixed">
<h4>My Footer</h4>
</div>

http://jsfiddle.net/Lu80dt6c/3/ http://jsfiddle.net/Lu80dt6c/3/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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