2013-11-03 71 views
36

引导3中有一种方法来正确对齐div吗?在引导3对齐div右

我知道抵消的可能性,但我想调整一个格式化的div到其容器的右侧,而它应该以全角移动视图为中心。班'拉右'不再工作了。他们忘了替换它还是我错过了一些明显的东西?

<div class="row"> 
    <div class="container"> 
    <div class="col-md-4"> 
     left content 
    </div> 
    <div class="col-md-4 col-md-offset-4"> 
     <!-- The next div has a background color and its own paddings and should be aligned right--> 
     <!-- It is now in the right column but aligned left in that column --> 
     <div class="yellow_background">right content</div> 
    </div> 
    </div> 
</div> 

舒尔我知道如何做到这一点在CSS中,但它可以在纯引导3?

+1

拉右工作在这里... – Gavin

回答

36

你的意思是这样的:

HTML

<div class="row"> 
    <div class="container"> 

    <div class="col-md-4"> 
     left content 
    </div> 

    <div class="col-md-4 col-md-offset-4"> 

     <div class="yellow-background"> 
     text 
     <div class="pull-right">right content</div> 
     </div> 

    </div> 
    </div> 
</div> 

CSS

.yellow-background { 
    background: blue; 
} 

.pull-right { 
    background: yellow; 
} 

完整的例子可以在Codepen找到。

48

的类上拉权是引导3 仍有见'helper classes' here

右拉式由

.pull-right { 
    float: right !important; 
} 

不上的风格和内容的详细信息定义,这是很难说。

它绝对正确的拉在此JSBIN 当页面比990px​​宽 - 这是当COL-MD造型踢, 引导3为移动第一和所有。

1

我想你尝试对准格中的内容的权利,以弥补已推自己的权利DIV,这里的一些代码和LIVE sample
FYI:.pull-right只推DIV向右,但不是div内的内容。

HTML:

<div class="row"> 
    <div class="container"> 
    <div class="col-md-4 someclass"> 
     left content 
    </div> 
    <div class="col-md-4 col-md-offset-4 someclass"> 
     <div class="yellow_background totheright">right content</div> 
    </div> 
    </div> 
</div> 

CSS:

.someclass{ /*this class for testing purpose only*/ 
    border:1px solid blue; 
    line-height:2em; 
} 

.totheright{ /*this will align the text to the right*/ 
    text-align:right; 
} 

.yellow_background{ 
    background-color:yellow; 
} 

另一个修改:

... 
<div class="yellow_background totheright"> 
    <span>right content</span> 
    <br/>image also align-right<br/> 
    <img width="15%" src="https://www.google.com/images/srpr/logo11w.png"/> 
</div> 
... 

希望它会清除你的问题

-2

添加offset8到您的CL屁股,例如:

<div class="offset8">aligns to the right</div> 
+0

请编辑您的答案,并通过提供更多的细节,以提高其质量。 –