[英]Moving button inside of a table-cell to center
I have a button inside a table-cell.我在表格单元格中有一个按钮。 Table is something like this:
表是这样的:
<b-table
v-if="rows.length"
:thead-tr-class="'bug-report-thead'"
:tbody-tr-class="'bug-report-tbody'"
:items="rows"
:fields="columnsToDisplay"
:sort-compare="sortTableByKey"
:striped="true"
:bordered="true"
:outlined="true"
:hover="true"
:no-sort-reset="true"
:show-empty="true"
:filter="filter"
@filtered="onFiltered"
:empty-text="emptyText"
:sort-desc="true"
:caption-top="true"
responsive>
/b-table>
And button is something like this,按钮是这样的,
<template slot="iinstances" slot-scope="row">
<div v-if=" total_rows>0 && row.item.imProdInstDet!=''">
<b-button style="text-align: center" :variant="'primary'" @click.stop="row.toggleDetails" class="mr-1">
More Details
</b-button>
</div>
</template>
How can I move the above button to centre of the cell?如何将上面的按钮移动到单元格的中心? I have tried,
margin:auto; display:block;
我试过了,
margin:auto; display:block;
margin:auto; display:block;
as listed here: how to center the button inside a table cell but this doesn't seem to work.如此处所列: 如何在表格单元格中居中按钮,但这似乎不起作用。
There is a property in field object for custom style and classes by each column.字段 object 中有一个属性,用于每列的自定义样式和类。
Try something like that:尝试这样的事情:
<template>
<div id="app">
<b-table striped hover :items="items" :fields="fields">
<template v-slot:cell(button)="data">
<b-button>test</b-button>
</template>
</b-table>
</div>
</template>
<script>
export default {
name: 'App',
data: () => ({
fields: ['id', 'name', { key: 'button', class: 'text-center' }],
items: [
{ id: 1, name: 'Row 1' },
{ id: 2, name: 'Row 2' },
{ id: 3, name: 'Row 3' },
{ id: 4, name: 'Row 4' },
{ id: 5, name: 'Row 5' },
],
}),
};
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.