2012-03-16 55 views

回答

19

你只需要更新保存在您的列表項的文本.ui-li-desc元素的CSS:

​.ui-page .ui-content .ui-listview .ui-li-desc { 
    white-space : normal; 
}​ 

這裏是一個演示:http://jsfiddle.net/Xc6PJ/

一些好的文檔對於white-spacehttps://developer.mozilla.org/en/CSS/white-space

這是一個示例li jQuery Mobile的之後,從我的測試listview ST-項目已初始化它:

<li class="ui-li ui-li-static ui-body-c"> 
    <h3 class="ui-li-heading">Sample Title</h3> 
    <p class="ui-li-desc"> 
     Sample Content Sample Content Sample Content Sample Content Sample Content Sample Content Sample Content Sample Content Sample Content Sample Content Sample Content 
    </p> 
</li> 
+0

謝謝!這解決了我的問題。 – 2014-10-07 17:27:45

5

我的建議是在<li>中使用一個DIV並設置你想要的特定的行爲,而不是改變了jQuery移動的整體行爲CSS。有了這個,你可以只有特定的事情按照你想要的方式行事。

+0

你可以做到這一點是純粹的CSS(不需要額外的元素)。您只需要將一個類(或其他類型的標識符)應用於list-element並在CSS selcetor中使用該類(或其他類)。 – Jasper 2014-02-26 20:57:16

3

li部分的內部添加divstyle="white-space:normal;"部分強制自動換行。

+0

完美,簡單,甜美的解決方案。 – 2015-12-09 09:51:45

3

在jQuery Mobile的1.4.4這個工作:

.ui-listview > li p { 
    white-space: normal; 
}