css - 如何居中图像和左右浮动文本?

标签 css twitter-bootstrap

我想将图像居中,然后将文本(或按钮) float 到左侧和右侧,如下图所示:

enter image description here

我知道您不能 float: center; 并且通过快速网络搜索,每个推荐的解决方案都有点乱七八糟。那么我该如何为这种特定情况设置 css 呢?我正在使用 Twitter Bootstrap 来获得任何有值(value)的东西(在这种情况下可能没有)。

最佳答案

您可以float: left 所有具有百分比宽度的 3 列。像这样:

#col1, #col2, #col3 {
     float: left;
} 

#col1, #col3 {
    width: 25%;
}

#col2 {
    width: 50%;
    text-align: center;
}

此外,如果您使用的是 Twitter Bootstrap,您可能需要使用 Fluid Grid System有 3 列。

关于css - 如何居中图像和左右浮动文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14219460/

相关文章:

html - 使标题菜单固定位置(主题tesseract)

css - 试图使 flex 元素等高但 flex-grow 不起作用

css - 将 Bootstrap 模式放入 div 包装器而不是 body

javascript - 使用 Browser Profile Enterprise 设置时 IE11 的 Twitter Bootstrap 问题

javascript - 为什么 BootStrap TokenField 输入未在 POST 请求中传递?

css - Bootstrap 与我的 CSS 重叠

html - Jekyll 构建 Bootstrap 导航栏

html - 在 HTML 中不使用 <br> 换行

html - AngularJS - 让元素在值更改后仅可见几秒钟

html - Bootstrap 导航问题 : Can't Change the Background Color of Different Columns