Mobile Friendly Jquery Modal Box?

2019-07-23 05:10发布

问题:

Any suggestions on a Jquery Modal box that is mobile friendly?

回答1:

There is a modal in JQM already. It's called Dialog, just like the JQ UI version.

Here is example code:

<!DOCTYPE html> 
<html> 
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>Single page template</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
</head> 
<body> 

<div data-role="page" id="main">

    <div data-role="header">
        <h1>Single page</h1>
    </div><!-- /header -->

    <div data-role="content">   

        <a href="#modal" data-rel="dialog">Open dialog</a> 
     </div><!-- /content -->

    <div data-role="footer">
        <h4>Footer content</h4>
    </div><!-- /footer -->
</div><!-- /page -->

<!-- modal -->
<div data-role="page" id="modal">

    <div data-role="header" data-theme="e">
        <h1>Dialog (modal)</h1>

    </div><!-- /header -->

    <div data-role="content" data-theme="d">    
        <h2>Modal</h2>
        <p>Content of Modal Goes Here</p>       

    </div><!-- /content -->


    <div data-role="footer">
        <h4>Page Footer</h4>
    </div><!-- /footer -->
</div><!-- /page modal -->

</body>
</html>

JQM Dialog docs: http://jquerymobile.com/demos/1.0/docs/pages/page-dialogs.html