html - 无法让 float div 与文本对齐中心一起使用

标签 html css css-float

任何人都知道我如何让它工作:

<div width="100%" style="background-color:#0000FA;">
    <div style="float:left;width:110px;background-color:#F1F1F1;">
        <form  action="/dashboard/" id="PREVIOUS_MONTH" method="post">
            <input type="submit" class="button-orange" value="Previous Month">
        </form>
    </div>

    <div style="float:left;width:300px;text-align:center;">
            January
    </div>

    <div style="float:right;width:80px;background-color:#F9F0F0;">
        <form action="/dashboard/" id="NEXT_MONTH" method="post">
            <input type="submit" class="button-orange" value="Next Month">
        </form>
    </div>
</div>

我想要的只是让左手边的左按钮,右边的右按钮 以及要在两个按钮之间对齐的文本,即在外部 div 的中间。

我试过使用 display:inline 作为文本按钮,但我没有成功。

所以我的输出是:

左按钮--------------------文本-------------------- --向右按钮

提前致谢

最佳答案

如果你不 float 文本那么你应该很好。您还需要将 float 放在文本之前。

<div width="100%" style="background-color:#0000FA;">
    <div style="float:left;width:110px;background-color:#F1F1F1;">
        <form  action="/dashboard/" id="PREVIOUS_MONTH" method="post">
            <input type="submit" class="button-orange" value="Previous Month">
        </form>
    </div>

    <div style="float:right;width:80px;background-color:#F9F0F0;">
        <form action="/dashboard/" id="NEXT_MONTH" method="post">
            <input type="submit" class="button-orange" value="Next Month">
        </form>
    </div>

    <div style="text-align:center;">
            January
    </div>
</div>

http://jsfiddle.net/BXp9v/2/

关于html - 无法让 float div 与文本对齐中心一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14300518/

相关文章:

javascript - jQuery AJAX 调用返回 [object Object]

javascript - 通过javascript从数组中设置div的背景

css - 偏移 centeres li 列表中的最后一个 li

html - 兄弟 float div 延伸相同的垂直距离

javascript - 如何使用 HTML5 来验证日期范围?

HTML 选择框 - 去掉箭头及其空格

css - 菜单和搜索自动完成的下拉菜单在 IE 中不起作用

javascript - 响应式设计 float 标题,主要和旁边有 3 种方式

javascript - 使用 jquery 将值传递给 popover 上的 iframe

css - CSS3 webkit 动画的交叉兼容浏览器编码?