简体   繁体   中英

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:

<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? I would also need elements within the td to be vertically aligned.

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/

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; } td button { float: right; }

sorted.

Hi now give to float element in your buttton

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

Demo

or

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

Css

.fr{
float:right;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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