【问题标题】:primeng picklist buttons width shrinkprimeng 选项列表按钮宽度缩小
【发布时间】:2019-01-16 19:14:15
【问题描述】:

我正在使用primeng 选项列表。我发现当目标或源控件中的选项长度较大时,中间的选项列表控件按钮会变小。我的选择列表代码如下

<p-pickList [source]="availableFormula" [target]="selectedFormula" sourceHeader="Available Formula"
      targetHeader="Selected Formula" [responsive]="true" filterBy="Name" dragdrop="true" dragdropScope="cars"
      sourceFilterPlaceholder="Search by Formula" targetFilterPlaceholder="Search by Formula" [sourceStyle]="{'height':'300px'}"
      [targetStyle]="{'height':'300px'}" showSourceControls="false" [showTargetControls]="false" (onSourceSelect)="formulaSelectEvent($event)"
      (onTargetSelect)="formulaSelectEvent($event)">
      <ng-template let-availableFormula pTemplate="item">
        <div class="ui-helper-clearfix">
          <div style="font-size:14px;float:right;margin:15px 5px 0 0">{{availableFormula.Name}}</div>
        </div>
      </ng-template>
    </p-pickList>

我在 CSS 覆盖中尝试了以下方法以使其不会缩小,但没有任何效果。

 .ui-picklist-buttons{
width: 100% !important;

}

【问题讨论】:

  • 如果您不复制问题,我们如何帮助您?请分享复制您的特定问题所需的最少代码。
  • 需要什么代码?
  • 我们如何帮助您处理您询问的图像和小段 css
  • 我添加了我的选择列表代码
  • css 样式规则是否应用于元素?当你检查那个元素时你看到了吗? (被划掉的事件)

标签: css angular primeng


【解决方案1】:

问题不在于按钮的宽度。

问题在于 picklist-buttonspicklist-listwrapper 被声明为 table-celltd's 根据内容增加它们的宽度。 (不像块元素)

如果您只想固定列宽,请在 ui-picklist 上使用 table-layout: fixed。如果问题是一个列表中有一个很长的单词,请在picklist-listwrapperui-picklist-item 上使用word-break: break-word

见下例

.fixed {
  table-layout: fixed;
  width: 100%;
}

.buttons {
  width: 20%;
  background: blue;
}
.list {
  width: 40%;
  background: red;
}

.not-fixed .list {
  word-break: break-word;
}
<!–– with table-layout: fixed  but no break-word -->
<table class="fixed">
  <tr>
    <td class="list">40percent</td>
    <td class="buttons">button</td>
    <td class="list">veryveryveasasasarylongtextthatdoesntfitin40percent</td>
  </tr>
</table>

<!–– with break-word -->
<table class="not-fixed">
  <tr>
    <td class="list">40percent</td>
    <td class="buttons">button</td>
    <td class="list">veryveryveasasasarylongtextthatdoesntfitin40percent</td>
  </tr>
</table>

【讨论】:

  • 我在我的 css override .ui-picklist-listwrapper{ word-wrap: break-word !important; } 它没有工作
  • @SGN 你能给我看一张完整的图片吗(如果你不能在这里复制代码)?
  • 我添加了图片。
  • @SGN 试试ui-picklist-item { word-break: break-all;}。分词不是自动换行
  • 它现在可以工作了。我认为这个问题不需要投票
猜你喜欢
  • 1970-01-01
  • 2020-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-30
  • 2023-04-05
  • 2019-02-03
相关资源
最近更新 更多