在表格单元格中使用CSS使内部div高度为100%

pgee70

我有一个表格/表格行/表格单元格布局,并且我希望内部div高度对齐。我看到了这篇文章:高度:<div>中<div>内的显示为:table-cell的100%询问了相同的问题,但是我的代码似乎无法获得相同的结果。

我有一个JS解决方案,但确实希望不需要它。

我的问题是:如何仅使用CSS使nkda框与其他两个框的高度相同?

这是一个JS小提琴http://jsfiddle.net/a1opo1kd/

html

<div class="forum-tag-summaries">

  <dl class="tags-rows">
    <div class="row tags-row">
      <div id="tag-wrapper-2" class="tag-wrapper" data-row="0" data-ftg_id="2" data-i="0">
        <div class="alert alert-info" id="ui-id-1">
          <dt>
            <div class="fl" title="Created 1 year ago by Mr Peter GEE">
              clinical
            </div>
            <button class="btn btn-xs btn-edit ml-5">
              <span class="fa fa-pencil">
              </span>
            </button>
            <div class="fr text-muted">
              x&nbsp;2
            </div>
          </dt>
          <br>
          <dd>
            <div class="text-muted view" title="">
              Clinical questions relating to medication reviews.
            </div>
            <div class="edit hidden text-muted">
              <textarea data-id="2" name="ftg_description" class="mw maxlength-enabled ajax" maxlength="1000" placeholder="Enter a description for this tag…">
                Clinical questions relating to medication reviews.
              </textarea>
            </div>
          </dd>
      </div>
  </div>
  <div id="tag-wrapper-6" class="tag-wrapper active" data-row="0" data-ftg_id="6" data-i="1">
    <div class="alert alert-info" id="ui-id-2">
      <dt>
        <div class="fl" title="Created 2 days ago by Mr Peter GEE">
          nkda
        </div>
        <button class="btn btn-xs btn-edit ml-5">
          <span class="fa fa-pencil">
          </span>
        </button>
        <div class="fr text-muted">
          x&nbsp;1
        </div>
      </dt>
      <br>
      <dd>
        <div class="text-muted view" title="">
          no known drug allergies
        </div>
        <div class="edit hidden text-muted">
          <textarea data-id="6" name="ftg_description" class="mw maxlength-enabled ajax" maxlength="1000" placeholder="Enter a description for this tag…">
            no known drug allergies
          </textarea>
        </div>
      </dd>
    </div>
  </div>
  <div id="tag-wrapper-3" class="tag-wrapper" data-row="0" data-ftg_id="3" data-i="2">
    <div class="alert alert-warning" id="ui-id-3">
      <dt>
        <div class="fl" title="Created 2 days ago by Mr user 1">
          RMMR
        </div>
        <button class="btn btn-xs btn-edit ml-5">
          <span class="fa fa-pencil">
          </span>
        </button>
        <div class="fr text-muted">
          x&nbsp;1
        </div>
      </dt>
      <br>
      <dd>
        <div class="text-muted view" title="">
          <span class="text-danger">
            This tag does not have a description, please enter one!
          </span>
        </div>
        <div class="edit hidden text-muted">
          <textarea data-id="3" name="ftg_description" class="mw maxlength-enabled ajax" maxlength="1000" placeholder="Enter a description for this tag…">
          </textarea>
        </div>
      </dd>
    </div>
  </div>
  </div>
  <div class="row tags-row">
    <div id="tag-wrapper-4" class="tag-wrapper" data-row="1" data-ftg_id="4" data-i="0">
      <div class="alert alert-warning" id="ui-id-4">
        <dt>
          <div class="fl" title="Created 2 days ago by Mr user 1">
            hypertension
          </div>
          <button class="btn btn-xs btn-edit ml-5">
            <span class="fa fa-pencil">
            </span>
          </button>
          <div class="fr text-muted">
            x&nbsp;1
          </div>
        </dt>
        <br>
        <dd>
          <div class="text-muted view" title="">
            <span class="text-danger">
              This tag does not have a description, please enter one!
            </span>
          </div>
          <div class="edit hidden text-muted">
            <textarea data-id="4" name="ftg_description" class="mw maxlength-enabled ajax" maxlength="1000" placeholder="Enter a description for this tag…">
            </textarea>
          </div>
        </dd>
      </div>
  </div>
  <div id="tag-wrapper-5" class="tag-wrapper" data-row="1" data-ftg_id="5" data-i="1">
    <div class="alert alert-warning" id="ui-id-5">
      <dt>
        <div class="fl" title="Created 2 days ago by Mr user 1">
          poly pharmacy
        </div>
        <button class="btn btn-xs btn-edit ml-5">
          <span class="fa fa-pencil">
          </span>
        </button>
        <div class="fr text-muted">
          x&nbsp;1
        </div>
      </dt>
      <br>
      <dd>
        <div class="text-muted view" title="">
          <span class="text-danger">
            This tag does not have a description, please enter one!
          </span>
        </div>
        <div class="edit hidden text-muted">
          <textarea data-id="5" name="ftg_description" class="mw maxlength-enabled ajax" maxlength="1000" placeholder="Enter a description for this tag…">
          </textarea>
        </div>
      </dd>
    </div>
  </div>
  <div id="tag-wrapper-7" class="tag-wrapper" data-row="1" data-ftg_id="7" data-i="2">
    <div class="alert alert-danger" id="ui-id-6">
      <dt>
        <div class="fl" title="Created 23 hours ago by user 1">
          test
        </div>
        <button class="btn btn-xs btn-edit ml-5">
          <span class="fa fa-pencil">
          </span>
        </button>
        <div class="fr text-muted">
          x&nbsp;0
        </div>
      </dt>
      <br>
      <dd>
        <div class="text-muted view" title="">
          <span class="text-danger">
            This tag does not have a description, please enter one!
          </span>
        </div>
        <div class="edit hidden text-muted">
          <textarea data-id="7" name="ftg_description" class="mw maxlength-enabled ajax" maxlength="1000" placeholder="Enter a description for this tag…">
          </textarea>
        </div>
      </dd>
    </div>
  </div>
  </div>
  </dl>
</div>

的CSS

    .btn-edit{background-color:transparent;}
  dl.tags-rows {
  display: table;
  height: auto;
  }
  dl.tags-rows .tags-row {display: table-row;}
  dl.tags-rows .tags-row .tag-wrapper {
      display: table-cell;
      height: 100%;
      width: 33%;
      min-width: 33%;
      padding: 5px;}
  .ml-5{margin-left:5px;}
  .fl{float:left;}
  .fr{float:right;}

屏幕截图示例 屏幕截图示例

阿尔贝尔

非常简单。在您的情况下,这就是您所需要的:

dl.tags-rows {
    display: table;
    height: 1px; /* IE fix, any small height */
}

.alert {
    display: inline-table;
    height: 100%;
    width: 100%;
    vertical-align: top;
}

演示: http //jsfiddle.net/a1opo1kd/5/

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

CSS表格单元格100%宽度

在表格单元格中具有高度为100%的图像的居中链接(导航按钮)

表格单元格内100%的高度div在Firefox上不起作用

使表格单元格的边框为表格宽度的100%

如何在iOS中更改内部表格视图单元格的单元格高度?

在Firefox下,表格单元格内的Textarea不会调整为单元格高度

在使用表格单元格的垂直居中div时,我需要将div宽度设为100%

使表格单元格为父级的100%宽度

HTML:让表格单元格使用所有可用高度

使用最小高度的单元格自动调整表格视图

CSS表格单元格未填充屏幕宽度的100%

jQuery以获取表格单元格的高度

使<textarea>填充表格单元格的高度

表格视图的动态单元格高度

使用Javascript控制表格单元格的内部文本

在Chrome中使用css3写入模式在表格单元格中显示垂直文本

表格单元格div之间的CSS线

我可以使用CSS为表格列着色而不给单个单元格上色吗?

在表格单元格中使用ng-repeat

何时在Matlab中使用单元格,矩阵或表格

Google表格-在脚本的OFFSET中使用单元格的值

在表格单元格中使用“检查”图标

在 Swift 中使用 Parse 删除表格视图单元格

在表格的所有单元格中使用 flexbox 样式垂直堆叠行的单元格

根据使用javascript的值为表格的单元格着色

CSS表格布局-减小窗口大小时表格单元格的高度不会减小

使用Word VBA根据单元格值为表格中的单元格着色

使用 CSS 在整个表格单元格上放置链接

使用 .css 文件向表格单元格添加内容