首页 > web前端 > H5教程 > 小强的HTML5移动开发之路(40)——jqMobi中实践header定义的几种方式

小强的HTML5移动开发之路(40)——jqMobi中实践header定义的几种方式

黄舟
发布: 2017-02-15 13:08:53
原创
1832 人浏览过

一、定义全局的header

这个header是所有panel默认的header,需要在

内部,也就是和

同一级的位置添加一个header 标签,并且id必须是header

例如:


<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title>jqMobi</title>

<link href="css/af.ui.css" rel="stylesheet" type="text/css"/>
<link href="css/icons.css" rel="stylesheet" type="text/css"/>
<script src="appframework.js" type="text/javascript"></script>
<script src="ui/appframework.ui.js" type="text/javascript"></script>
</head> 
<body> 
	<p id="afui">
    	<header id="header">
                <a id="backButton" href="javascript:;" class="button" >Back</a>
                <h1>Single Page App</h1>
        </header>
        <p id="content">
            <p id="home">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
                    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
                    Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                </p>
            </p>
            <p id="sketch">
                <p>sketch</p>
            </p>
        </p>
        <p id="navbar">
                <a href="#home" id=&#39;navbar_home&#39; class=&#39;icon home&#39;>home</a>
                <a href="#sketch" id=&#39;navbar_pencil&#39; class=&#39;icon pencil&#39;>Sketch</a>
                <a href="#picture" id=&#39;navbar_picture&#39; class=&#39;icon picture&#39;>Picture</a>
        </p>
    </p>
</body>
</html>
登录后复制

运行效果



二、panel引入header标签


内部,也就是和

同一级的位置顶一个header 标签,并且命名id。 然后再需要这个header的pane添加一个属性data-header="custom_header"


<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title>jqMobi</title>
<link href="css/af.ui.css" rel="stylesheet" type="text/css"/>
<link href="css/icons.css" rel="stylesheet" type="text/css"/>
<script src="appframework.js" type="text/javascript"></script>
<script src="ui/appframework.ui.js" type="text/javascript"></script>
</head> 
<body> 
	<p id="afui">
		
        <p id="content">
            <p id="home" data-header="custom_header">
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
                    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
                    Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                </p>
            </p>
            <p id="sketch">
                <p>sketch</p>
            </p>
        </p>
        <header id="custom_header">
            <a id="backButton" href="javascript:;" class="button" >Back</a>
            <h1>Single Page App</h1>
        </header>
        <p id="navbar">
                <a href="#home" id=&#39;navbar_home&#39; class=&#39;icon home&#39;>home</a>
                <a href="#sketch" id=&#39;navbar_pencil&#39; class=&#39;icon pencil&#39;>Sketch</a>
                <a href="#picture" id=&#39;navbar_picture&#39; class=&#39;icon picture&#39;>Picture</a>
        </p>
    </p>
</body>
</html>
登录后复制


三、给每个panel自定义header

在需要自定义的panel的内部定义一个header,这个header此时只属于该panel


<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title>jqMobi</title>
<link href="css/af.ui.css" rel="stylesheet" type="text/css"/>
<link href="css/icons.css" rel="stylesheet" type="text/css"/>
<script src="appframework.js" type="text/javascript"></script>
<script src="ui/appframework.ui.js" type="text/javascript"></script>
</head> 
<body> 
	<p id="afui">
        <p id="content">
            <p id="home" class="panel">
                <header>
                    <a id="backButton" href="javascript:;" class="button" >Back</a>
                    <h1>Single Page App</h1>
                </header>
                <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
                    Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
                    Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
                </p>
            </p>
            <p id="sketch">
                <p>sketch</p>
            </p>
        </p>
       
        <p id="navbar">
                <a href="#home" id=&#39;navbar_home&#39; class=&#39;icon home&#39;>home</a>
                <a href="#sketch" id=&#39;navbar_pencil&#39; class=&#39;icon pencil&#39;>Sketch</a>
                <a href="#picture" id=&#39;navbar_picture&#39; class=&#39;icon picture&#39;>Picture</a>
        </p>
    </p>
</body>
</html>
登录后复制

四、给相应的标签定义title属性,系统也会自动生成header



<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title>jqMobi</title>
<link href="css/af.ui.css" rel="stylesheet" type="text/css"/>
<link href="css/icons.css" rel="stylesheet" type="text/css"/>
<script src="appframework.js" type="text/javascript"></script>
<script src="ui/appframework.ui.js" type="text/javascript"></script>
</head> 
<body> 
	<p id="afui">
    	<p id="content">
        	<p id="home" title="首页" class="panel" selected="true"
            	data-footer="custom_footer">
            
            </p>
            <p id="about" title="关于我们" class="panel"
            	data-footer="custom_footer">
                
           	</p>
            <header id="custom_header">
            	<h1>首页</h1>
            </header>
            <footer id="custom_footer">
            	<a href=&#39;#home&#39; class=&#39;icon home&#39;>首页</a>
                <a href=&#39;#about&#39; class=&#39;icon info&#39;>关于我们</a>
            </footer>
            <nav>
            	<p class=&#39;title&#39;>Home</p>
                <ul>
                	<li><a class="icon home mini" href="#main">Home</a></li>
                </ul>
            </nav>
        </p>
    </p>
</body>
</html>
登录后复制



以上就是小强的HTML5移动开发之路(40)——jqMobi中实践header定义的几种方式 的内容,更多相关内容请关注PHP中文网(www.php.cn)!








来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板