【问题标题】:Display html table over Div Elements so that the table contents is not overlapping?在 Div 元素上显示 html 表格以使表格内容不重叠?
【发布时间】:2017-02-13 14:11:38
【问题描述】:

HTML页面

<div *ngIf="visibleTournament">
  <div class = "row">
    <div *ngFor="let entry of competitionTeams | keys">
      <div class="col-md-4">
        <div>
          <div (click) = "entry.hideme = !entry.hideme" (mouseleave)= "entry.hideme = false">
            <div class = "groupBox"><div class="placed"><h3><span class = "label label-warning">Group - {{entry.key}}</span></h3></div></div>
          </div>
            <div class="well box" [hidden] = "!entry.hideme">
              <table class="table">
                  <thead class="thead-inverse">
                  <tr>
                    <th>#</th>
                    <th>Team</th>
                    <th>Played Games</th>
                    <th>Points</th>
                    <th>Goals</th>
                    <th>GA</th>
                    <th>GD</th>
                  </tr>
                  </thead>
                </table>

当我单击现有 div 顶部的相应 div 而不是 div 从其位置移动时,我想显示一个表格。还要增加表格宽度,以便于查看。

我的 CSS

.avatar{
  width:30px;
  height:30px;
  margin-right: 10px;
}

.inline{
  display: inline-block;
  margin: 10px 20px;
}

.check{
  min-width: 500px;
}

.selector{
  cursor: pointer;
}
.placed{
  margin: 0 auto;
}

.box{
  position: relative;
  text-align: center;
  background: #ccffda;
  padding: 10px 20px;
  width : 100%;
  height: 100%;
  border: darkgray 1px solid;
}


.groupBox{
  text-align: center;
  background: lightsteelblue;
  padding: 20px 20px;
  margin: 2px;
  border: darkgray 1px solid;
  cursor: pointer;
}


.fix{
  position: absolute;
}

如果现有元素,如何使表格显示在顶部,并增加表格的宽度超过 col 宽度。

我不是 CSS 专家,请帮忙

【问题讨论】:

    标签: html css twitter-bootstrap-3


    【解决方案1】:

    您可以使用absolute positioning 从流中删除元素。这样,它就不会下推后续的组框。这也将使元素呈现 in front of 其他元素,这也是您想要的。

    当一个元素有position: absolute 时,它的坐标是相对于同样将position 设置为绝对或relative 的父元素解析的。因此,您可能希望在祖先上设置position: relative,以便您可以将topleft 相对于组对齐,同时仍然允许组为自己腾出空间。

    【讨论】:

    • 问题是当使用绝对位置时,只显示最后三个元素,因为我正在使用 ngFor 并且所有 div 都在一个循环中。我无法弄清楚这一点。我知道它会给出绝对值,但我无法弄清楚
    猜你喜欢
    • 1970-01-01
    • 2013-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多