我有两个元素在同一条线上,向左和向右浮动。
<style type="text/css">
#element1 {float:left;}
#element2 {float:right;}
</style>
<div id="element1">
element 1 markup
</div>
<div id="element2">
element 2 markup
</div>
I need for element2 to line up next to element1 with about 10 pixels of padding between the two. The problem is that element2's width can change depending on content and browser (font size, etc.) so it's not always lined up perfectly with element1 (I can't just apply a margin-right and move it over).
我也无法更改标记。
有没有统一的方法把它们排列起来?我尝试了用百分比右边距,我尝试了用负边距处理 element1以使 element2更接近(但无法正常工作)。