我曾将问题发布到http://doctype.com/within-same-line-have-center-element-right-most-element,但没有得到很好的答案。我贴在这里,希望能获得良好的反馈;)在同一行内,有一个中心元素和最右边的元素
<div style="float:right">
right most, same line as hello world and will not push hello world!
</div>
<div style="text-align:center">hello world</div>
目前,最右边的元素,从页面的中心推动的“hello world”出来的。我怎样才能避免这种情况?
我希望
- 你好世界仍处于中心
- 正确的元素仍然是同一条线上世界,你好
- 正确的元素是在最右边的
- 都是顶最
谢谢。
我尝试了一些别人的建议,但它不会工作。
<div style="text-align:center; width:100%;">
Hello World
<div style="float:right">right most, same line as hello world and will not push hello world!</div>
<div style="clear:both"></div>
</div>
对于上面的代码,我测试了IE8。它们不会在同一行。我用firefox 3.6.8进行了测试,“Hello World”会被右侧的元素向左推。
辉煌。它只是工作! – 2010-08-12 03:39:17
另一个不理解CSS模型的例子,也就是不理解“position”的瘟疫。 – John 2015-04-04 20:43:28
@John我一定错过了你的回答,否则我会很高兴地认可它的优越性。 – 2015-04-04 22:46:45