我已经搜索了这个问题超过2个小时了,我不明白为什么这么简单的东西不起作用。
我尝试在我的页脚中实现一个导航栏,但我不知道为什么jquery添加一些按钮,布局变得很糟糕。
这是我的代码:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>VeryGoodTrip</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Destinations</h1>
</div><!-- /header -->
<div data-role="content" data-theme="c">
<ul data-role="listview">
<li><a href="index.html">
<img src="img/corse.png" />
<h3>Corse</h3>
<p>Corse</p>
</a></li>
<li><a href="index.html">
<img src="img/golf.png" />
<h3>Golf du Lyon</h3>
<p>Golf du Lyon</p>
</a></li>
<li><a href="index.html">
<img src="img/lerins.png" />
<h3>Iles de lerins</h3>
<p>Iles de lerins</p>
</a></li>
<li><a href="index.html">
<img src="img/menton.png" />
<h3>Menton</h3>
<p>Menton</p>
</a></li>
<li><a href="index.html">
<img src="img/monaco.png" />
<h3>Monaco</h3>
<p>Monaco</p>
</a></li>
<li><a href="index.html">
<img src="img/nice.png" />
<h3>Nice</h3>
<p>Nice</p>
</a></li>
<li><a href="index.html">
<img src="img/tropez.png" />
<h3>Saint-Tropez</h3>
<p>Saint-Tropez</p>
</li>
</ul>
</div><!-- /content -->
<div data-role="footer" data-position="fixed">
<div data-role="navbar" data-iconpos="right">
<ul>
<li><a href="index.html" data-icon="refresh" class="ui-state-persist ui-btn-active">Destinations</a></li>
<li><a href="index.html" data-icon="refresh">Activités</a></li>
<li><a href="index.html" data-icon="refresh">Planning</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
</div><!-- /page -->
</body>
这就是我用firebug得到的:
<div data-position="fixed" data-role="footer" class="ui-footer ui-bar-a ui-footer-fixed fade ui-fixed-overlay" role="contentinfo" style="top: -155px;">
<a href="index.html" class="ui-btn-left ui-btn ui-btn-up-a ui-btn-corner-all ui-shadow" data-theme="a">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-btn-text"></span>
</span>
</a>
<div data-iconpos="right" data-role="navbar" class="ui-navbar" role="navigation">
**<a href="index.html" data-theme="a" class="ui-btn ui-btn-up-a ui-btn-icon-right">
<span class="ui-btn-inner">
<span class="ui-btn-text"></span>
</span>
</a>**
<ul class="ui-grid-c">
<a href="index.html" class="ui-block-a ui-btn ui-btn-icon-right ui-btn-up-a" data-theme="a">
<span class="ui-btn-inner">
<span class="ui-btn-text"></span>
</span>
</a>
<li class="ui-block-b">
<a href="index.html" data-theme="a" class="ui-btn ui-btn-icon-right ui-btn-up-a">
<span class="ui-btn-inner">
<span class="ui-btn-text"></span>
</span>
</a>
<a class="ui-state-persist ui-btn-active ui-btn ui-btn-icon-right ui-btn-up-a" data-icon="refresh" href="index.html" data-theme="a">
<span class="ui-btn-inner">
<span class="ui-btn-text">Destinations</span>
<span class="ui-icon ui-icon-refresh ui-icon-shadow"></span>
</span>
</a>
</li>
<li class="ui-block-c">
<a data-icon="refresh" href="index.html" data-theme="a" class="ui-btn ui-btn-icon-right ui-btn-up-a">
<span class="ui-btn-inner">
<span class="ui-btn-text">Activit?s</span>
<span class="ui-icon ui-icon-refresh ui-icon-shadow"></span>
</span>
</a>
</li>
<li class="ui-block-d">
<a data-icon="refresh" href="index.html" data-theme="a" class="ui-btn ui-btn-up-a ui-btn-icon-right">
<span class="ui-btn-inner">
<span class="ui-btn-text">Planning</span>
<span class="ui-icon ui-icon-refresh ui-icon-shadow"></span>
</span>
</a>
</li>
</ul>
</div><!-- /navbar -->
</div>
正如你所看到的,下面两个按钮不应该在这里有任何想法吗?
<a href="index.html" class="ui-btn-left ui-btn ui-btn-up-a ui-btn-corner-all ui-shadow" data-theme="a">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-btn-text"></span>
</span>
</a>
<a href="index.html" data-theme="a" class="ui-btn ui-btn-up-a ui-btn-icon-right">
<span class="ui-btn-inner">
<span class="ui-btn-text"></span>
</span>
</a>
由于
答案 0 :(得分:3)
您忘记关闭<a>
代码,因此HTML元素未正确嵌套。问题出在data-role="content
div中的最后一个列表项:
<li>
<a href="index.html">
<img src="img/tropez.png" />
<h3>Saint-Tropez</h3>
<p>Saint-Tropez</p>
</li>
应该是:
<li>
<a href="index.html">
<img src="img/tropez.png" />
<h3>Saint-Tropez</h3>
<p>Saint-Tropez</p>
</a>
</li>
以上是上述修复程序的演示:http://jsfiddle.net/9q6My/(我在我添加的结束</a>
标记旁边添加了评论)
从上面格式化的代码中可以看出,我确保缩进每个嵌套标记,以便我可以看到每个标记都已正确关闭。