2

我已经搜索这个问题超过 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>

这就是我用萤火虫得到的:

<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>

谢谢

4

1 回答 1

3

您忘记关闭<a>标签,因此 HTML 元素没有正确嵌套。问题在于data-role="contentdiv 中的最后一个列表项:

            <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> (我在我添加的结束标签旁边添加了一条评论)

正如您从我上面格式化的代码中看到的那样,我确保缩进每个嵌套标签,以便我可以看到每个标签都已正确关闭。

于 2012-02-24T00:38:46.750 回答