jquery - bootstrap 3 在它们的 div 中对齐元素

标签 jquery html css twitter-bootstrap-3

我一直在尝试 Bootstrap ,但一直很难让元素在他们的 div 中对齐。 即在我的 fiddle 中,我试图将内容居中。(位置/电话号码) 第 2 行我试图让它的列表与关于购物者排到一边。

我已经尝试过导航行和其他一些东西。我能找到正确方向的指针吗?请 :)

我见过其他类似的问题,但我发现的问题并没有真正帮助我提出问题。对不起,如果它是重复的。 JsFiddle

  .footer .col-sm-3{
  overflow: hidden;
  }
  .footer-widget {
  margin-bottom: 68px;
  }

  .footer-widget .container {
  border-top: 1px solid #FFFFFF;
  padding-top: 15px;
  }

  .single-widget h2 {
  color: #666663;
  font-family: 'Roboto', sans-serif;
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 22px;
  text-transform: uppercase;
  }

  .single-widget h2 i{
  margin-right:15px;
  }

  .single-widget ul li a{
  color: #8C8C88;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 300;
  padding: 5px 0;
  display:inline-block;
  }

  .single-widget ul li a i {
  margin-right: auto;
  }

  .single-widget ul li a:hover{
  background:none;
  color:#FE980F;
  }

最佳答案

Bootstrap 使用 12 列,这意味着例如

<div class="row">
    <div class="col-sm-6">I'm the left half</div>
    <div class="col-sm-6">I'm the right half</div>
</div>

在第一行中,您使用 col-sm-2,它仅占屏幕的 1/6。要居中对齐,您真的不需要 Bootstrap ,只需在 css 中执行 text-align:center 即可。可能只有部分文档有行/列,所以如果您只想居中,我会省略第一个。

对于第二部分,您只需增加 jsfiddle 框的大小,它就会彼此相邻对齐。但同样,您应该使用总和为 12 的值。

举个例子: http://jsfiddle.net/6u4cj25h/

请注意我是如何用 xs 替换 sm 的,这意味着即使在小屏幕上,列也不会折叠。

关于jquery - bootstrap 3 在它们的 div 中对齐元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32532971/

相关文章:

javascript - 无法将 animatescrollTop 与 jscrollpane 一起使用?

jquery - 根据浏览器的窗口大小调整固定高度的图像

javascript - jQuery 淡化/动画不透明度到不同的显示类型然后阻止

html - flexbox 中文本对齐的媒体查询

html - 在 HTML 中使用超链接进行水平和垂直对齐

javascript - 使用 angularjs 处理 ajax 调用

javascript - jquery 在一个数组中搜索值,并将结果放入另一个数组中

python - html 格式的 matplotlib 文档

javascript - 匹配除尖括号之外的单词边界

javascript - 自定义复选框