jquerymobile-6 自适应header、footer和全屏视图

原文链接:http://blog.csdn.net/mengxiangyue/article/details/8502422

在开发的过程中我们开发的页面可能会非常的长,我们在页面的两端放置了header和footer。这样的页面当我们滚动的时候,header和footer会随着滚动而滚到屏幕外,这时候我们如果想操做header和footer必须再滚动回去。jquerymobile为我们考虑了这种情况,在这种情况下我们可以点击屏幕,然后消失的header和footer就会出现,再次点击的时候就又会消失。如果我们正在文章的开头,无论我们怎么点击这个header都不会消失,footer在底部一样。下面我看一段代码:

[html]  view plain  copy
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <title>Fixed Positioning Example</title>  
  5. <meta name="viewport" content="width=device-width, initial-scale=1">  
  6. <link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" />  
  7. <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>  
  8. <script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>  
  9. </head>  
  10.   
  11. <body>  
  12. <div data-role="page">  
  13.     <div data-role="header" data-position="fixed"><h1>My Header</h1></div>    
  14.     <div data-role="content">  
  15.     <p>     
  16.         ..........代表很长的内容,测试的时候请自己填满超过一个屏幕  
  17.     </div>          
  18.     <div data-role="footer" data-position="fixed"><h4>My Footer</h4></div>    
  19. </div>  
  20. </body>  
  21. </html>  

在上面的代码中主要是在header和footer中添加了data-position属性,并将其值设置为fixed。这样是达到了我们的效果,但是同样还有一个问题,有时候我们可能在开始和结尾的时候也能全屏查看。这时候我们只需要对上面的代码进行一下改造,修改代码如下即可:

[html]  view plain  copy
  1. <div data-role="page"  data-fullscreen="true">  

在page上添加data-fullscreen,并且设置为true就可以了。这样当我们点击的时候会全屏,再点击的时候就会header、footer都出现了。同样这个全屏可以使用在一些图片的预览上。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值