【问题标题】:Sticky header table in Angular with ui-scrollfix带有 ui-scrollfix 的 Angular 中的粘性标题表
【发布时间】:2016-10-25 17:37:09
【问题描述】:

滚动时如何修复表格的标题?我正在尝试这个,但它不起作用:

<body>
    <div ui-view="header"></div>
    <div ui-view="content"></div>
    <div ui-view="footer"></div>
</body>

内容:

<div class="table-responsive">
   <table class="table table-condensed">
      <thead>
         <tr class="well" ui-scrollfix>

使用 CSS:

.well {
  background : #eee;
}

.well.ui-scrollfix {
  position : fixed;
  background : #f00;
  top : 50;

}

我正在使用 bootstrap、angular、SPA,并使用 ng-repeat 从 MongoDB 数据库获取数据。非常感谢

【问题讨论】:

  • 它与角度无关!!!....阅读此affix
  • ui-scrollfix 来自 Angular,但它对我不起作用。

标签: css angularjs


【解决方案1】:

Bootstrap Affix Article

<div data-spy="affix" data-offset-top="60" data-offset-bottom="200">
   ...
</div>

<script>
$('#myAffix').affix({
    offset: {
    top: 100,
    bottom: function () {
    return (this.bottom = $('.footer').outerHeight(true))
   }}
  })
</script>

【讨论】:

  • 谢谢,但我证明了这一点,但它不起作用。可能是因为我有动态数据或者因为是表,我不知道
【解决方案2】:

html, body{
  margin:0;
  padding:0;
  height:100%;
}
section {
  position: relative;
  border: 1px solid #000;
  padding-top: 37px;
  background: #500;
      overflow-y: scroll;
    overflow-x: hidden;
}
section.positioned {
  position: absolute;
  top:100px;
  left:100px;
  width:800px;
  box-shadow: 0 0 15px #333;
}
.container {
 // overflow-y: auto;
  height: 200px;
}
table {
  border-spacing: 0;
  width:100%;
}
td + td {
  border-left:1px solid #eee;
}
td, th {
  border-bottom:1px solid #eee;
  background: #ddd;
  color: #000;
  padding: 10px 25px;
}
th {
  height: 0;
  line-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  color: transparent;
  border: none;
  white-space: nowrap;
}
th div{
  position: absolute;
  background: transparent;
  color: #fff;
  padding: 9px 25px;
  top: 0;
  margin-left: -25px;
  line-height: normal;
  border-left: 1px solid #800;
}
th:first-child div{
  border: none;
}
<section class="">
  <div class="container">
    <table>
      <thead>
        <tr class="header">
          <th>
            Table attribute name
            <div>Table attribute name</div>
          </th>
          <th>
            Value
            <div>Value</div>
          </th>
          <th>
            Description
            <div>Description</div>
          </th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>align</td>
          <td>left, center, right</td>
          <td>Not supported in HTML5. Deprecated in HTML 4.01. Specifies the alignment of a table according to surrounding text</td>
        </tr>
        <tr>
          <td>bgcolor</td>
          <td>rgb(x,x,x), #xxxxxx, colorname</td>
          <td>Not supported in HTML5. Deprecated in HTML 4.01. Specifies the background color for a table</td>
        </tr>
        <tr>
          <td>border</td>
          <td>1,""</td>
          <td>Specifies whether the table cells should have borders or not</td>
        </tr>
        <tr>
          <td>cellpadding</td>
          <td>pixels</td>
          <td>Not supported in HTML5. Specifies the space between the cell wall and the cell content</td>
        </tr>
        <tr>
          <td>cellspacing</td>
          <td>pixels</td>
          <td>Not supported in HTML5. Specifies the space between cells</td>
        </tr>
        <tr>
          <td>frame</td>
          <td>void, above, below, hsides, lhs, rhs, vsides, box, border</td>
          <td>Not supported in HTML5. Specifies which parts of the outside borders that should be visible</td>
        </tr>
        <tr>
          <td>rules</td>
          <td>none, groups, rows, cols, all</td>
          <td>Not supported in HTML5. Specifies which parts of the inside borders that should be visible</td>
        </tr>
        <tr>
          <td>summary</td>
          <td>text</td>
          <td>Not supported in HTML5. Specifies a summary of the content of a table</td>
        </tr>
        <tr>
          <td>width</td>
          <td>pixels, %</td>
          <td>Not supported in HTML5. Specifies the width of a table</td>
        </tr>
      </tbody>
    </table>
  </div>
</section>

【讨论】:

  • 谢谢,这和我想要的非常相似,只是表格内没有滚动。我想用浏览器的滚动条
  • 让我这样做
  • 最后我使用了github.com/cmelo/angular-sticky 指令。解释起来很长,但我的网络应用程序使用 angular,它是一个单页应用程序,仅使用 css 或引导程序不起作用,我不知道为什么。还是谢谢你
  • 但根据您最初的要求,它与角度无关。
猜你喜欢
  • 2020-01-30
  • 1970-01-01
  • 2021-09-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多