【发布时间】:2013-12-21 07:48:17
【问题描述】:
假设我有以下 UI:
<div>
<span class="normal">text</span>
<span class="pull-right">blah</span>
</div>
和风格:
.pull-right {
float: right;
/* What should I put here to make "blah" appear on the same line as text? */
}
div {
float: left; /* for wrapping the contents */
border: 1px solid green; /* to help see the bounds */
}
.normal {
border: 1px solid blue; /* to help see the bounds */
}
实际结果:当在浏览器(我的情况是 Chrome)中显示时,blah 显示在 text 的下方和右侧,div 几乎与两个文本。
这几乎就是我想要的。
预期结果:我希望blah 显示在同一行中text 的右侧,div(绿色框)的宽度为text 和blah 的宽度加在一起(没有指定任何特定的宽度值。
这是上面最小示例和我遇到相同问题的原始上下文的小提琴: http://jsfiddle.net/TWiStErRob/5TruW/
我应该如何设置blah 的样式以使其按预期工作?
【问题讨论】:
标签: html css css-float alignment