1

我正在使用 Phonegap 和 JQuery mobile 创建一个使用按钮的应用程序,该按钮的内容(标题)是通过 ajax 请求获取的,并且可能很长,所以我想要多行按钮。我使用以下 css 搜索并找到了一种方法:

.ui-btn-inner{
    white-space: normal !important;
}

但我无法让它工作。

我试图将它放在页面头部的样式标签之间,然后使用 style='' 放在按钮本身的 html 代码中。我还尝试将那段代码放在 css 文件中并将其链接到页面,但它也不起作用,即使我将此文件放在与我的 HTML 相同的文件夹中。

这是我创建按钮的 JS 的摘录:

for ( var i = 0; i < quizz.questionnaire[index_quest - 1].propositions.length; i++) {
    if (quizz.questionnaire[index_quest - 1].fin) {
        if (i + 1 == quizz.questionnaire[index_quest - 1].reponse) {
            code_source += "<a href='pageFinQz.html' data-role='button' onclick='localStorage.localScore=++score'>";
            code_source += quizz.questionnaire[index_quest - 1].propositions[i];
            code_source += "</a><br/>";
        } else {
            code_source += "<a href='pageFinQz.html' data-role='button'>";
            code_source += quizz.questionnaire[index_quest - 1].propositions[i];
            code_source += "</a><br/>";
        }
    } else if (i + 1 == quizz.questionnaire[index_quest - 1].reponse) {
        code_source += "<a href='#' data-role='button' onclick='mapQuestion(quizz, ++index_quest); localStorage.localScore=++score; return false' rel='external'>";
        code_source += quizz.questionnaire[index_quest - 1].propositions[i];
        code_source += "</a><br/>";
    } else {
        code_source += "<a href='#' data-role='button' onclick='mapQuestion(quizz, ++index_quest); return false' rel='external'>";
        code_source += quizz.questionnaire[index_quest - 1].propositions[i];
        code_source += "</a><br/>";
    }
}

我的 HTML 的标题是:

<meta http-equiv="Content-Type" content="text-html" charset="UTF-8"/>
<link rel="stylesheet" type="text/css" href="../lib/jqm/jquery.mobile-1.3.0.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="../lib/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../lib/cordova-2.4.0.js"></script>
<script type="text/javascript" src="../lib/jqm/jquery.mobile-1.3.0.js"></script>

style.css 与我的 HTML 位于同一文件夹中,并且包含以下内容:

.ui-btn-inner{
    white-space: normal !important;
}

我真的不明白为什么 css 似乎不起作用,因为它很简单,但也许我错过了一些明显的东西。

在此先感谢您的帮助。

4

1 回答 1

0

如果没有 jsfiddle 或示例,很难看到发生了什么,但为什么不尝试使用:

display: block;

直接在链接元素上<a href="" style="display: block;"></a>

从外观上看.ui-btn-inner是指按钮的内部,并且代码中的超链接似乎没有分配给它的类。

于 2013-08-28T11:55:44.780 回答