简体   繁体   English

如何在表格单元格(td)中定位元素,使得一个元素左对齐而另一个元素对齐?

[英]How can I position elements within a table cell (td) such that one element is left aligned and the other right aligned?

Given the html code below: 鉴于下面的HTML代码:

<tr>
   <td>Some text <a href="">Some link</a> <button>Some Button</button></td>
</tr> 

I would like to achieve something like this: 我想实现这样的目标:

表的图像

Would I need to add additional mark-up such as wrapping divs to float one to the left and the other to the right? 我是否需要添加额外的标记,例如将div包装为左侧浮动,另一侧浮动? I would also need elements within the td to be vertically aligned. 我还需要在td内的元素垂直对齐。

What would be the best way to achieve this with minimal additional mark-up. 以最小的额外加价实现这一目标的最佳方法是什么。

I have sample code here: http://jsfiddle.net/stormwild/AAw78/17/ 我在这里有示例代码: http//jsfiddle.net/stormwild/AAw78/17/

A related problem is how to keep alignment of the text consistent among table cells when one cell contains a floated element? 一个相关的问题是当一个单元格包含浮动元素时如何保持表格单元格之间文本的一致性?

在此输入图像描述

CSS: td button { float: right; } CSS: td button { float: right; } td button { float: right; }

sorted. 排序。

Hi now give to float element in your buttton 嗨现在给你的buttton浮子元素

<button style="float:right;">Some Button</button>

Demo 演示

or 要么

<button class="fr">Some button</button>

Css CSS

.fr{
float:right;
}

暂无
暂无

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

相关问题 如何使第一个元素与右侧对齐,其他元素在左侧对齐? - How to make the first element aligned to the right and the other elements in the left of that first? 如何创建一个表,其TD左对齐,其兄弟姐妹右对齐? - How do I create a table with a TD aligned to the left and its sibling aligned to the right? 如何在同一行上有两个DIV,一个不带HTML表格,一个左对齐,一个右对齐? - How can I have two DIV s on the same line , one aligned to the left and one aligned to the right without an HTML table? 如何强制 html 表的“td”元素中的单独元素显示内联(从左到右)? - How can I force separate elements within a “td” element of an html table to display inline (left to right)? 如何使两个对象水平对齐(一个在另一个的右侧)并居中放置一个? - How can I have two objects aligned horizontally (one to the right of the other) and center the left one? 如果表格中的单元格中有文本,如何将文本添加到与单元格最右侧对齐的同一个单元格? - If I have text in a cell within a table, how can I add text to the same cell just aligned to the far right of the cell? 如何修改Bootstrap表单,以使某些字段在屏幕左侧对齐,而其他字段在右侧对齐? - How can I modify a Bootstrap form so that some fields are aligned on the left side of the screen, while other fields are aligned on the right side? 在布尔玛模态页脚中,如何在同一水平位置具有左对齐和右对齐的内容? - How can I have left- and right-aligned content at the same horizontal position in a Bulma modal footer? 如何将 dd 和 dt 元素设置在同一行,dt 右对齐和 dd 左对齐? - How do I style dd and dt elements to be on the same line with dt right aligned and dd left aligned? 如何获取文本区域的行,并将其放入左右对齐的元素集中,每一行都在“:”上分割? - How can I take the lines of a textarea and put them in a left and right aligned set of elements split on “:” for each row?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM