角度材质表-表内边框

2024-05-28

I am using Angular material table and I want to set border inside the table, Using CSS I was able to set border: Normal case [enter image description here
but when the content of a particular cell increases border of the neighbor cells don't grow and the table looks pretty bad cell with extra content enter image description here
here is the CSS:

`.example-container {
  display: flex;
  flex-direction: column;
  max-height: 500px;
  min-width: 300px;
}

.mat-table {
  overflow: auto;
  max-height: 500px;
}
.mat-column-name{
  border-left: 1px solid grey;
  min-height: 48px;

}
.mat-column-weight{
  border-left: 1px solid grey;

   min-height: 48px;

.mat-column-symbol{
 border-left: 1px solid grey;
   min-height: 48px;
}`

HTML`

<!--- Note that these columns can be defined in any order.
      The actual rendered columns are set as a property on the row definition" -->

<!-- Position Column -->
<ng-container matColumnDef="position">
  <mat-header-cell *matHeaderCellDef> No. </mat-header-cell>
  <mat-cell *matCellDef="let element"> {{element.position}} </mat-cell>
</ng-container>

<!-- Name Column -->
<ng-container matColumnDef="name">
  <mat-header-cell *matHeaderCellDef> Name </mat-header-cell>
  <mat-cell *matCellDef="let element"> {{element.name}} </mat-cell>
</ng-container>

<!-- Weight Column -->
<ng-container matColumnDef="weight">
  <mat-header-cell *matHeaderCellDef> Weight </mat-header-cell>
  <mat-cell *matCellDef="let element"> {{element.weight}} </mat-cell>
</ng-container>

<!-- Symbol Column -->
<ng-container matColumnDef="symbol">
  <mat-header-cell *matHeaderCellDef> Symbol </mat-header-cell>
  <mat-cell *matCellDef="let element"> {{element.symbol}} </mat-cell>
</ng-container>

<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>

`


方法2:最终,我找到了解决方案,因为材质使用弹性布局,我们可以使用 CSSalign-self: stretch; /* Stretch 'auto'-sized items to fit the container */使用align-self的结果:拉伸 https://i.stack.imgur.com/7T6gz.png

这是更新后的 CSS

    `.example-container {
      display: flex;
      flex-direction: column;

      flex-basis: 300px;
    }

    .mat-table {
      overflow: auto;
      max-height: 500px;
    }

     .mat-column-name{
    border-right: 1px solid grey;
    align-self: stretch;
    text-align: center


    }
    .mat-column-position{
    border-right: 1px solid grey;
    align-self: stretch;
    text-align: center;

    }
    .mat-column-weight{
    border-right: 1px solid grey;
    align-self: stretch;
    text-align: center;

    } 
    .mat-column-symbol{

    text-align: center;
    align-self: stretch;
    }
   .mat-column-weight{
       align-self: stretch;
    } `
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

角度材质表-表内边框 的相关文章

  • 单击即可切换背景颜色和过渡

    这看起来应该很容易 但我真的找不到办法做到这一点 动画 http doir ir css gif http doir ir css gif 当您单击这些相应的链接时 我需要更改和过渡页面的背景颜色 我见过的最接近触发这种类型转换的事情是 仅
  • PrimeNG 数据表日期范围过滤器

    过滤日期范围 https stackblitz com edit angular fpowo5 file app components transactionList transactionList html 7C 数据表 https ww
  • 限制到 agm-map 中的特定国家/地区

    下面是我的代码 我可以在地图上绘制点 但我希望我的地图仅限于一个国家 在 agm map 中如何实现这一点 例如 我希望它仅限于西澳大利亚 地图 html
  • 将 Angular 对象绑定到 Angular2 中的模型驱动形式

    I have created custom controls in component class with binding objects to form element in html but there is an error mes
  • 如何使CSS背景图像响应? [复制]

    这个问题在这里已经有答案了 好的 所以我遇到了这个使背景图像响应的解决方案 响应式 CSS 背景图片 https stackoverflow com questions 12609110 responsive css background
  • 使用 div 代替 table 进行布局

    我想知道什么方法最好将表格布局替换为 div 我自己也尝试过一些 但它让我的 4x4 div 非常混乱 我猜当有经验做这样的事情时 这并不是很难完成 但我对 div 都是新手 并试图学习这一点 看看这个并分享您对表格是否应该保持原样或者是否
  • 为什么 Bootstrap 按钮下拉菜单在 iOS 上不起作用?

    看起来甚至连引导演示在这里 http twitter github com bootstrap components html buttonDropdowns不适用于 iOS 您似乎无法在 iPhone 或 iPad 上从中选择项目 有解决
  • 我如何在ajax应用程序中找到未使用的css?

    我一直在搜索 但找不到任何 ff 插件或 javascript 来查找 ajax 应用程序中未使用的 css 除尘选择器 http www sitepoint com dustmeselectors 可以进行网站抓取 但我正在寻找检查加载内
  • Angular2从模块导入组件/服务

    我正在开发一个 Angular2 最终应用程序 它 当前 有两个模块 CoreModule 包含共享组件 服务 AppModule 应用程序的根模块 应用程序模块 Created by jamdahl on 9 21 16 Angular
  • 在 Angular2 中使用 ngFor 进行多重嵌入

    我对 angular2 还很陌生 我正在尝试制作一个名为 的小角度组件 grid 它只是使用嵌入来重新排列其内容 它的模板 网格组件模板 grid component ts div class grid div class row div
  • 如何获取div背景图像上的锚标记?

    HTML div a href http www facebook com au a div css facey float left width 32px height 32px background url file C Users U
  • td 内的文本可以随 td 一起调整大小吗? (是其高度的百分比?)

    我有一个 100 占屏幕的表格 里面有 3x3 9 个单元格 每个单元格占 33 到目前为止 一切都很好 这是一个干净 可扩展的井字棋游戏 问题在于 TD 内的文本不会随比例缩放 有没有办法说 我希望文本大小为 TD 高度的 30 或者其他
  • Twitter Bootstrap:按钮下拉列表中的图标

    Here http jsfiddle net DjHyQ 是 jsfiddle 上的链接 其中包含一些演示 它在 Chrome 甚至 IE 中运行良好 但在 FF 中图标会下降 我怎样才能解决这个问题而不用负边距或类似的东西来提升它们 我不
  • 如何使 :focus, :active 与 :hover 相同

    有没有简单的方法使 focus 和 active 表现得像 hover 通常我写 class a hover class a active class a focus 但我只想写一个 hover 规则 并且 focus active 看起来
  • 右侧对齐不浮动

    我有一个聊天小部件 我正在向其中添加一些样式 但是 我很难使 用户 聊天气泡与屏幕右侧对齐 当我使用向右浮动和向左浮动 另一侧 时 div 不再正确定位 因为它们似乎只是转到相对 div 的右侧 我希望它也能够附加 div 这将导致溢出 y
  • 检查标记坐标是否在边界内

    我在用着leafletAngular 6 应用程序中的地图 我获取每个项目的位置信息为 lat xx lng xx 我还得到了边界对象 它描述了地图当前可见的区域 它随着拖动和缩放而变化 边界对象如下所示 northEast lat 76
  • 使用Rxjs映射函数时如何保留对象属性大小写

    我是 Angular2 的新手 正在使用 http 服务从 asp net mvc webapi 获取数据 API返回的数据格式如下所示 RequestResponse public string Message get set publi
  • 如何在JavaFX中获得狭窄的进度条?

    正如标题所说 我需要制作一个细进度条 我用过这个 progressBar setMaxHeight 0 1 progressBar setPrefHeight 0 1 但这行不通 有人有想法吗 你必须搞乱样式才能让它变小 我真的建议看看ca
  • 与基线和文本区域垂直对齐

    我试图让标签与文本区域中第一行文本的基线对齐 天真的尝试 div style display inline block div
  • 在特定路线中添加类 - Angular 2

    当我在某条路线上时 我正在尝试添加课程 代码在我的 AppComponent 中 我使用 ngClass Component selector my app template a Some html code 然后我在同一个 app com

随机推荐