gpt4 book ai didi

css - 如何在 angular-ui-grid 单元格中居中按钮?

转载 作者:技术小花猫 更新时间:2023-10-29 11:09:49 25 4
gpt4 key购买 nike

我定义了一列如下:

{
name: 'button',
displayName: '',
cellClass: 'ui-grid-vcenter',
enableColumnMenu: false,
enableFiltering: false,
enableSorting: false,
cellTemplate: '<div><button ng-click="grid.appScope.rowButtonHandler(row.entity.id)">clicky</button></div>'
}

导致:

<div class="ui-grid-cell ng-scope ui-grid-coluiGrid-010 ui-grid-vcenter" ui-grid-cell="" ng-class="{ 'ui-grid-row-header-cell': col.isRowHeader }" ng-repeat="(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name">
<div class="ng-scope">
<button ng-click="grid.appScope.rowButtonHandler(row.entity.id)"></button>
</div>
</div>

我想让这个按钮垂直和水平居中。在水平方向上有效,但在垂直方向上,我似乎无法正确使用 CSS。这是我的一般镜头:

.ui-grid-vcenter div {
text-align: center;
vertical-align: middle !important;
background-color: yellow !important;
}

在这种 AngularJS 网格中,一个单元格中的内容如何居中?

最佳答案

使用相对位置:

.ui-grid-vcenter div {
background-color: yellow !important;
text-align:center;
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}

关于css - 如何在 angular-ui-grid 单元格中居中按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30607173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com