jquery-mobile - 如何使用 jquery mobile 创建 100% 高度的 div?

标签 jquery-mobile

如何创建具有 100% 高度的 id=test 的 div?

<div data-role="page" id="device1">
    <div data-role="header">
        <h1>Title</h1>
    </div><!-- /header -->
    <div data-role="content">
      <div data-role="fieldcontain">
        <input type="range" name="slider1" id="slider1" value="0" min="0" max="255"  />
      </div>
      <div id=test height=100%>
      </div>    
    </div><!-- /content -->
<div data-role="footer" data-position="fixed">
    </div><!-- /footer -->
</div><!-- /page -->

最佳答案

好的,这是我给你的。但是请记住,如果页面的内容很高,这可能不太有用。滑动区域是内容下方的所有内容。因此,随着内容区域变大,滑动区域变小。

<!DOCTYPE html> 
<html>
<head>
    <meta charset="UTF-8">
    <title>jQuery Swipe</title>

    <link href="jquery-mobile/jquery.mobile-1.0b3.min.css" rel="stylesheet" type="text/css"/>
    <script src="jquery-mobile/jquery.min.js" type="text/javascript"></script>
    <script src="jquery-mobile/jquery.mobile-1.0b3.min.js" type="text/javascript"></script>

    <script src="phonegap.js" type="text/javascript"></script>

    <script>
        $(document).ready(function() {

            // Set the initial window (assuming it will always be #1
            window.now = 1;

            //get an Array of all of the pages and count
            windowMax = $('div[data-role="page"]').length; 

           $('.swipeArea').bind('swipeleft', turnPage);
           $('.swipeArea').bind('swiperight', turnPageBack);
        });

        // Named handlers for binding page turn controls
        function turnPage(){
            // Check to see if we are already at the highest numbers page            
            if (window.now < windowMax) {
                window.now++
                $.mobile.changePage("#device"+window.now, "slide", false, true);
            }
        }

        function turnPageBack(){
            // Check to see if we are already at the lowest numbered page
            if (window.now != 1) {
                window.now--;
                $.mobile.changePage("#device"+window.now, "slide", true, true);
            }
        }
        </script> 

        <style>
            body, div[data-role="page"], div[data-role="content"], .swipeArea {
                height: 100%;
                width: 100%;
            }
    </style>
</head> 
<body> 

<div data-role="page" id="device1"">
    <div data-role="header">
        <h1>Page One</h1>
    </div>
    <div data-role="content">   
        Content 
        <div class=swipeArea></div>
    </div>

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

<div data-role="page" id="device2" style="height: 100%">
    <div data-role="header">
        <h1>Content 2</h1>
    </div>
    <div data-role="content" style="height: 100%">  
        Content     
        <div data-role="fieldcontain">
            <label for="slider">Input slider:</label>
            <input type="range" name="slider" id="slider" value="0" min="0" max="100"  />
        </div>
        <div class=swipeArea></div>
    </div>
    <div data-role="footer"  data-position="fixed">
        <h4>Page Footer</h4>
    </div>
</div>

<div data-role="page" id="device3" style="height: 100%">
    <div data-role="header">
        <h1>Content 3</h1>
    </div>
    <div data-role="content" style="height: 100%">  
        Content     
        <div class=swipeArea></div>
    </div>
    <div data-role="footer"  data-position="fixed">
        <h4>Page Footer</h4>
    </div>
</div>

<div data-role="page" id="device4" style="height: 100%">
    <div data-role="header">
        <h1>Content 4</h1>
    </div>
    <div data-role="content" style="height: 100%">  
        Content     
        <div class=swipeArea></div>
    </div>
    <div data-role="footer"  data-position="fixed">
        <h4>Page Footer</h4>
    </div>
</div>

</body>
</html>

关于jquery-mobile - 如何使用 jquery mobile 创建 100% 高度的 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7541780/

相关文章:

jQUery Mobile 共享页眉和页脚

javascript - 如何在 jQuery Mobile 中检测/查询当前正在进行的变更页面/转换?

javascript - jquery 移动圆形导航后退按钮

jquery-ui - 如何删除 jqueymobile Web 应用程序中的滚动条?

javascript - jQuery Mobile 动态改变按钮颜色

javascript - JQuery Mobile 想要在按下后退按钮时删除数据

javascript - 如何根据所选 ListView 项目使按钮表现不同?

javascript - jQuery Mobile - 内部 #page 导航仅在页面首次加载时使用双击

javascript - 清空 Javascript 对象 (Jquery Mobile)

css - 修改 jQuery Mobile 以允许标题显示在省略号之前的 2 行上?