表格单元格边框未延伸到行高

时间:2018-03-14 15:20:46

标签: css css-tables

我正在使用display:table-cell来显示日历显示。

当我有一天包含大量文本时,正方形比该行上的其他正方形大,但行上的其他div不会扩展其边框以匹配新高度。

我在这里做错了吗?

见plunker:

.calendar-week-container {
  display: table;
  width:100%; 
}
.row-container {
  display: table-row;
  width:100%; 
}
.calendar-day{
    display: table-cell;
    min-height:50px;
    float:left;
    width:20%;
    
    border-top:1px solid red;
    border-left:1px solid red;
}

    <div class="calendar-week-container">
      <div class="row-container">
          <div class="calendar-day">
            My Day 1
          </div>
          <div class="calendar-day">
            My Day 2
             <br>
            asdasd
            <br>
            asdasdads <br>
            asdasd
            <br>
            asdasdads
          </div>
                <div class="calendar-day">
            My Day 3
          </div>
          <div class="calendar-day">
            My Day 4
           
          </div>
        </div>
      <div class="row-container">
                <div class="calendar-day">
            My Day 5
          </div>
                <div class="calendar-day">
            My Day 6
          </div>
                <div class="calendar-day">
            My Day 7
          </div>
                <div class="calendar-day">
            My Day 8
          </div>
        </div>
        </div>
{{1}}

1 个答案:

答案 0 :(得分:2)

删除“cell”div上的float - 不确定为什么表格布局中存在。

.calendar-week-container {
  display: table;
  width:100%; 
}
.row-container {
  display: table-row;
  width:100%; 
}
.calendar-day{
    display: table-cell;
    min-height:50px;
    width:20%;
    
    border-top:1px solid red;
    border-left:1px solid red;
}
    <div class="calendar-week-container">
      <div class="row-container">
          <div class="calendar-day">
            My Day 1
          </div>
          <div class="calendar-day">
            My Day 2
             <br>
            asdasd
            <br>
            asdasdads <br>
            asdasd
            <br>
            asdasdads
          </div>
                <div class="calendar-day">
            My Day 3
          </div>
          <div class="calendar-day">
            My Day 4
           
          </div>
        </div>
      <div class="row-container">
                <div class="calendar-day">
            My Day 5
          </div>
                <div class="calendar-day">
            My Day 6
          </div>
                <div class="calendar-day">
            My Day 7
          </div>
                <div class="calendar-day">
            My Day 8
          </div>
        </div>
        </div>