Twitter bootstrap Twitter上的响应性文本对齐';s引导程序2.x

Twitter bootstrap Twitter上的响应性文本对齐';s引导程序2.x,twitter-bootstrap,responsive-design,text-alignment,Twitter Bootstrap,Responsive Design,Text Alignment,在bootstrap中,我试图通过将两段文本(一个标签,a,一些内容,B)彼此靠近来实现一种分组设计,如下所示: A (right-aligned) | B (left-aligned) 在引导中使用响应性布局,直到网格堆叠在狭窄的窗口上,这看起来很棒。然后它变成: | A (right-aligned) B (left-aligned) | 。。。看起来这两者似乎不再相关 我更喜欢堆叠后,元素要么居中,要么左对齐 我知道我

在bootstrap中,我试图通过将两段文本(一个标签,a,一些内容,B)彼此靠近来实现一种分组设计,如下所示:

A (right-aligned) | B (left-aligned)
在引导中使用响应性布局,直到网格堆叠在狭窄的窗口上,这看起来很棒。然后它变成:

                       |      A (right-aligned)
B (left-aligned)       |
。。。看起来这两者似乎不再相关

我更喜欢堆叠后,元素要么居中,要么左对齐

我知道我可以使用.visible-*和.hidden-*类来修复这个问题,但这感觉像是一个黑客。是否有一种简单的方法可以更改文本对齐方式以响应网格的引导堆叠部分?

要右对齐(默认为左对齐),可以在跨度上使用文本对齐:右对齐。要使此响应功能仅在大屏幕上使用媒体查询:

@media (min-width:768px)
{
  .text-right-responsive {text-align:right;}
  .text-left-responsive {text-align:left;}
}  
html:

向右拉/向左拉类将浮动添加到元素中。因此,要使用它们,您需要一个额外的包装器:

<div class="container">
<div class="row">
  <div class="span6"><span class="pull-right">A (right-aligned)</span></div>
  <div class="span6"><span class="pull-left">B (left-aligned)</span></div>
</div> 
</div>

演示:

在Bootstrap3中,我使用更少的资源添加了以下内容:

/* Defaults */
.text-center-sm,
.text-center-md,
.text-center-lg,
.text-right-sm,
.text-right-md,
.text-right-lg { text-align: inherit; }

/* Define xs styles after defaults so they take precedence */
.text-center-xs { text-align: center; }
.text-right-xs { text-align: right; }

/* Small grid */
@media (min-width: @screen-tablet) {
  .text-center-sm, .text-center-xs { text-align: center; }
  .text-right-sm, .text-right-xs { text-align: right; }
}

/* Medium grid */
@media (min-width: @screen-desktop) {
  .text-center-md, .text-center-sm, .text-center-xs { text-align: center; }
  .text-right-md, .text-right-sm, .text-right-xs { text-align: right; }
}

/* Large grid */
@media (min-width: @screen-lg-desktop) {
  .text-center-lg, .text-center-md, .text-center-sm, .text-center-xs {
    text-align: center;
  }
  .text-right-lg, .text-right-md, .text-right-sm, .text-right-xs {
    text-align: right;
  }
}

如果您没有减少使用,请将
@屏幕平板电脑
更改为
768px
@屏幕桌面
更改为
992px
,和
@screen lg desktop
1200px

您是否尝试了
向左拉
向右拉
?使用最大宽度刚好短于元素组合宽度的媒体查询,并将a对齐到左侧
<div class="container">
<div class="row">
  <div class="span6"><span class="pull-right">A (right-aligned)</span></div>
  <div class="span6"><span class="pull-left">B (left-aligned)</span></div>
</div> 
</div>
@media (max-width:767px)
{
  .pull-right {float:none;}
  .pull-left {float:none;}
} 
/* Defaults */
.text-center-sm,
.text-center-md,
.text-center-lg,
.text-right-sm,
.text-right-md,
.text-right-lg { text-align: inherit; }

/* Define xs styles after defaults so they take precedence */
.text-center-xs { text-align: center; }
.text-right-xs { text-align: right; }

/* Small grid */
@media (min-width: @screen-tablet) {
  .text-center-sm, .text-center-xs { text-align: center; }
  .text-right-sm, .text-right-xs { text-align: right; }
}

/* Medium grid */
@media (min-width: @screen-desktop) {
  .text-center-md, .text-center-sm, .text-center-xs { text-align: center; }
  .text-right-md, .text-right-sm, .text-right-xs { text-align: right; }
}

/* Large grid */
@media (min-width: @screen-lg-desktop) {
  .text-center-lg, .text-center-md, .text-center-sm, .text-center-xs {
    text-align: center;
  }
  .text-right-lg, .text-right-md, .text-right-sm, .text-right-xs {
    text-align: right;
  }
}