html - 将元素放在居中元素旁边

标签 html css

我有一个表格,其中包含一个我试图居中的元素: http://jsfiddle.net/Ce3JB/

有没有办法让中间的元素在中心,旁边的两个元素在中心元素的两侧而不移动它(三个元素的大小不一样)?这是一个示例图:

|                             |
|        left ctr right       |
|                             |

               ^   ^
               |   |
               |  This and "left" are always next to ctr
               |
The position of the t remains here no matter what is on the left or right

我想要的是无论“右”或“左”的长度如何,元素“ctr”都固定在该列的中间。

基本上,我希望“ctr”位于中心,“left”尽可能向右移动直到达到“ctr”,“right”尽可能向左移动直到达到 ctr。

我当前在表格上的 align="center"属性与其所有内容的中心对齐。我希望它使用“ctr”的中心作为枢轴使所有内容居中(因此在这种情况下 t 应该位于表格的中心)。

最佳答案

使用 float CSS 属性。

在这里,你更新的 fiddle ,

http://jsfiddle.net/Ce3JB/1/

关于html - 将元素放在居中元素旁边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17992303/

相关文章:

javascript - 如果外部 div 宽度为 10%,如何通过垂直旋转使内部 div 达到 100% 宽度?

html - WordPress/HTML 代码 : Pictures don't get displayed properly on mobile view

html - Margin top 在 IE 6 中不起作用

c# - ASP.NET/ GridView : HeaderStyle-CssClass has no effect

javascript - MP4 视频无法在浏览器上播放

php - CSS、PHP、mySQL Loop - 根据变量更改 td 颜色

html - 如果 div 有边框,则不需要 1px 填充。仅在 Chrome

javascript - 禁用依赖于另一个选择框的选择选项

javascript - 如何在 HTML/JavaScript 中构建自定义可聚焦对象

html - 元素堆叠而不是与内联 block 对齐