css - 可折叠表格行不会超出单元格宽度

标签 css angularjs html-table accordion

我有一个带有 +/- 符号的可点击表格。当用户点击它时,它会在下方打开一个 div 以显示更多详细信息。我遇到的问题是可折叠的 div 仅与一个表列一样宽,而且我似乎无法将其设置为全宽。

这是折叠行的表格的屏幕截图:

enter image description here

这是展开后的样子:

enter image description here

我的 html 看起来像这样:

<div class="table-row" ng-repeat="work in item.work_history | orderBy: '-to' track by $index">
   <div class="table-cell" style="vertical-align: middle;" >
      <a class="flex collapsed"
         ng-class="{'accordion-toggle collapsed':work.campaign.length>0}"
         ng-if="work.campaign.length>0" data-toggle="collapse"
         ng-click="c.campaign(work)" href="#{{work.sys_id}}"
         role="button" aria-expanded="false" aria-controls="collapseDetails">
      </a>
   </div>
   <div class="table-cell">
      <a href="javascript:void(0)" title="Edit Work History"
         ng-click="c.newEntry(work.sys_id,'x_dnf_gw_found_work_history','newWork');">
        Edit
      </a>
   </div>
   <div class="table-cell">
      {{work.work_name}}
   </div>
   <div class="table-cell">
      {{work.from}}
   </div>
   <div class="table-cell">
      {{work.to}}
   </div>
   <div class="table-cell">
      <button title="Add Campaign" type="button" class="btn btn-link btn-xs"
              ng-click="c.newEntry(-1, 'x_campaigns','newWork')">
         Add Campaign
      </button>
   </div>
</div>
<div class="collapse" id="{{campaignDetails}}">
   <ul>
      <li ng-repeat="campaigns in c.campaign_details">
         {{campaigns.from}} - {{campaigns.to}}: {{campaigns.camp}}
      </li>
   </ul>
</div>

我知道为什么展开的详细信息显示在一个表格单元格中,但我不确定如何解决此样式问题。感谢您的帮助!

最佳答案

class "table-row" 添加到您的可折叠部分

<div class="table-row" ng-repeat="work in item.work_history | orderBy: '-to' track by $index">
   <div class="table-cell" style="vertical-align: middle;" >
      <a class="flex collapsed" ng-class="{'accordion-toggle collapsed':work.campaign.length>0}" ng-if="work.campaign.length>0" data-toggle="collapse" ng-click="c.campaign(work)" href="#{{work.sys_id}}" role="button" aria-expanded="false" aria-controls="collapseDetails"></a>
   </div>
   <div class="table-cell">
      <a href="javascript:void(0)" title="Edit Work History" ng-click="c.newEntry(work.sys_id,'x_dnf_gw_found_work_history','newWork');">Edit</a>
   </div>
   <div class="table-cell">
      {{work.work_name}}
   </div>
   <div class="table-cell">
      {{work.from}}
   </div>
   <div class="table-cell">
      {{work.to}}
   </div>
   <div class="table-cell">
      <button title="Add Campaign" type="button" class="btn btn-link btn-xs" ng-click="c.newEntry(-1, 'x_campaigns','newWork')">Add Campaign</button>
   </div>
</div>
<div class="collapse table-row" id="{{campaignDetails}}">
   <ul>
      <li ng-repeat="campaigns in c.campaign_details">
         {{campaigns.from}} - {{campaigns.to}}: {{campaigns.camp}}
      </li>
   </ul>
</div>

关于css - 可折叠表格行不会超出单元格宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50805731/

相关文章:

javascript - 在我的 Angular 模板中使用 &lt;style scoped>

javascript - 如何使用 Bootstrap 正确创建 block 引用

html - 更改 :hover – what other ways are there? 上图标图像的颜色

javascript - 是否可以使用 AngularJS 在 ng-click 中添加 ng-repeat $index 值?

javascript - Angular JS : Show/Close div based on select option without using controller or model

javascript - Angular.js 移动动画

django - 将 Django 模型输出为表格

html - 如何使用 CSS 使 TD 表现得像 TR(row)?

html - 在带有表格标签的基本 html 代码的 outlook 中没有得到正确的输出

html - IE7 中的 UL 对齐问题