简体   繁体   English

Html 表格按钮占用太多空间

[英]Html Table Button Taking too much space

I want make two buttons sit next to each other within the same cell.我想让两个按钮在同一个单元格中彼此相邻。 How can I go about that without having alot space in the cell.如果单元格中没有很多空间,我怎么能做到这一点。 Only Enough space to have the buttons sit in comfortable space between each other.只有足够的空间让按钮坐在彼此之间的舒适空间中。

I have used display: inline-block;我用过 display: inline-block; as well as display:block and style='white-space: nowrap'.以及 display:block 和 style='white-space: nowrap'。 Have looked at similar questions and their answers don't work with my project.看过类似的问题,他们的答案不适用于我的项目。

 <table> <tr> <th>Employee Name</th> <th>Email Address</th> <th>Action</th> </tr> <tr> <td>Johnny Depp</td> <td>hotdog69@gmail.com</td> <td> <button type="button">Add</button> <button type="button">Edit</button> </td> </tr> </table>

When one or two buttons are present within a cell, they create this super long horizontal cell.当一个单元格中有一个或两个按钮时,它们会创建这个超长的水平单元格。 The buttons are also far apart from each other.按钮也彼此远离。

You can use "table-layout:fixed" property to make your table use fixed width and assign width to "th" as per your choice.您可以使用“table-layout:fixed”属性使您的表格使用固定宽度并根据您的选择将宽度分配给“th”。 It will help you to adjust space of your table layout easily.它将帮助您轻松调整表格布局的空间。

For email id, use "word-break: break-all" property to break text instead of using "white-space: nowrap" property.对于电子邮件 ID,请使用“word-break: break-all”属性来中断文本,而不是使用“white-space: nowrap”属性。

 <table style="table-layout:fixed;text-align:left"> <tr> <th width="115px">Employee Name</th> <th width="105px">Email Address</th> <th width="90px">Action</th> </tr> <tr> <td>Johnny Depp</td> <td style="word-break:break-all;">hotdog69@gmail.com</td> <td> <button type="button">Add</button> <button type="button">Edit</button> </td> </tr> </table>

Maybe you need to use the command "colspan".也许您需要使用命令“colspan”。 For example...例如...

<tr>
    <th>Name</th>
    <th colspan="2">Address</th>
</tr>

Turns out a button's style was controlling all the buttons in my project.结果是一个按钮的样式控制了我项目中的所有按钮。 I should have given that button an id so it wouldn't control all the buttons in a general sense.我应该给那个按钮一个 id,这样它就不会在一般意义上控制所有按钮。

尝试在按钮或 td 标签上添加以下样式,

display:contents

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM