在Jquery Mobile的Listview中自动换行

时间:2017-01-17 19:19:34

标签: jquery-mobile word-wrap

有人可以帮助我为什么不能使用ui-block将文本包装在listview中但是它在listview之外工作正常吗?谢谢。代码和屏幕截图附件。

           <ul id="myDetList" data-role="listview" data-inset="true" style="word-wrap:break-word">
            <li style="word-wrap:break-word">
                <div class="ui-grid-b">
                    <div class="ui-block-a" style="width:5%; text-align:left; font-weight:bold; font-size:large; color:orange">2</div>
                    <div class="ui-block-b" style="width:87%; font-size:small; font-weight:bold; word-wrap:break-word">Count the long words in this sentence and tell me how can I wrap these within the ListView.</div>
                    <div class="ui-block-c" style="width:8%"><i class="fa fa-camera" style="color:gray"></i></div>
                    <div class="ui-block-a" style="width:5%;"></div>
                    <div class="ui-block-b" style="width:87%;"></div>
                    <div class="ui-block-c" style="width:8%"><i class="fa fa-video-camera" style="color:gray"></i></div>
                    <div class="ui-block-a" style="width:5%;"></div>
                    <div class="ui-block-b" style="width:87%;"></div>
                    <div class="ui-block-c" style="width:8%"><i class="fa fa-list-alt" style="color:gray"></i></div>
                </div>
            </li>
        </ul>

        <div class="ui-grid-b">
            <div class="ui-block-a" style="width:5%; text-align:left; font-weight:bold; font-size:large; color:orange">2</div>
            <div class="ui-block-b" style="width:87%; font-size:small; font-weight:bold;">Count the long words in this sentence and tell why does it wrap here and not up there?</div>
            <div class="ui-block-c" style="width:8%"><i class="fa fa-camera" style="color:gray"></i></div>
            <div class="ui-block-a" style="width:5%;"></div>
            <div class="ui-block-b" style="width:87%;"></div>
            <div class="ui-block-c" style="width:8%"><i class="fa fa-video-camera" style="color:gray"></i></div>
            <div class="ui-block-a" style="width:5%;"></div>
            <div class="ui-block-b" style="width:87%;"></div>
            <div class="ui-block-c" style="width:8%"><i class="fa fa-list-alt" style="color:gray"></i></div>
        </div>

Screen Results in emulator

1 个答案:

答案 0 :(得分:0)

CSS:

#myDetList>.ui-li-static {
  white-space: normal !important;
}

HTML:

<ul id="myDetList" data-role="listview" data-inset="true">
  <li>
    <div class="ui-grid-b">
      <div class="ui-block-a" style="width:5%; text-align:left; font-weight:bold; font-size:large; color:orange">2</div>
      <div class="ui-block-b" style="width:87%; font-size:small; font-weight:bold;">Count the long words in this sentence and tell me how can I wrap these within the ListView.</div>
      <div class="ui-block-c" style="width:8%"><i class="fa fa-camera" style="color:gray"></i></div>
      <div class="ui-block-a" style="width:5%;"></div>
      <div class="ui-block-b" style="width:87%;"></div>
      <div class="ui-block-c" style="width:8%"><i class="fa fa-video-camera" style="color:gray"></i></div>
      <div class="ui-block-a" style="width:5%;"></div>
      <div class="ui-block-b" style="width:87%;"></div>
      <div class="ui-block-c" style="width:8%"><i class="fa fa-list-alt" style="color:gray"></i></div>
    </div>
  </li>
</ul>