本文翻译自:How can I get my Twitter Bootstrap buttons to right align?
I have a simple demo here: 我在这里有一个简单的演示:
http://jsfiddle.net/HdeZ3/1/ http://jsfiddle.net/HdeZ3/1/
- One
- Two
I have an unordered list and for each list item I wish to have text on the left and then a right aligned button. 我有一个无序列表,对于每个列表项,我希望左侧有一个文本,然后有一个右对齐的按钮。 I have tried to use pull-right but this completely messes up the alignment. 我尝试使用向右拉,但这完全弄乱了对齐方式。 What am I doing wrong? 我究竟做错了什么?
参考:https://stackoom.com/question/12oG5/如何使我的Twitter-Bootstrap按钮正确对齐
- One
- Two
i just used layout..apply styles for li.. 我只是用布局..应用样式为李..
or 要么
- One
- Two
in CSS 在CSS中
li {
line-height: 20px;
margin: 5px;
padding: 2px;
}
Can you try a custom CSS aside the bootstrap CSS to see if any changes. 您能否在引导CSS之外尝试自定义CSS,以查看是否有任何更改。 Try 尝试
.move-rigth{
display: block;
float: right;
}
If it works then you can try manipulating what you have or adding other formatting to this and achieving what you desire. 如果可行,则可以尝试处理现有内容或为此添加其他格式并实现所需的功能。 Because you are using bootstrap doesn't mean if it doesn't offer you what you want then you just manage it. 因为您使用的是引导程序,并不意味着它不能为您提供所需的东西,那么您就可以对其进行管理。 You are working with your codes and so you command it to do as you say. 您正在使用您的代码,因此您可以按要求执行命令。 Cheers! 干杯!
Insert pull-right
into the class attribute and let bootstrap arrange the buttons. pull-right
插入class属性,然后让引导程序安排按钮。
For Bootstrap 2.3 , see: http://getbootstrap.com/2.3.2/components.html#misc > Helper classes > .pull-right. 对于Bootstrap 2.3 ,请参阅: http ://getbootstrap.com/2.3.2/components.html#misc>帮助器类> .pull-right。
For Bootstrap 3 , see: https://getbootstrap.com/docs/3.3/css/#helper-classes > Helper classes. 对于Bootstrap 3 ,请参阅: https : //getbootstrap.com/docs/3.3/css/#helper-classes > Helper类。
For Bootstrap 4 , see: https://getbootstrap.com/docs/4.0/utilities/float/#responsive 对于Bootstrap 4 ,请参阅: https : //getbootstrap.com/docs/4.0/utilities/float/#sensitive
The pull-right
command was removed and replaced with float-right
or in general to float-{sm,md,lg,xl}-{left,right,none}
删除了pull-right
命令,并将其替换为float-right
或通常替换为float-{sm,md,lg,xl}-{left,right,none}
在twitter bootstrap 3中尝试向右拉类
class="btn pull-right"
Sorry for replying to an older already answered question, but I thought I'd point out a couple of reasons that your jsfiddle does not work, in case others check it out and wonder why the pull-right class as described in the accepted answer doesn't work there. 对不起,回复到旧的已经回答的问题,但我想我会指出,有几个原因,你的jsfiddle不行,万一别人检查出来,不知为什么作为接受的答案中描述的拉正确的类没有按在那儿不工作。
element instead. 更好的是,改为使用
元素。 working fiddle: http://jsfiddle.net/3ejqufp6/ 工作提琴: http : //jsfiddle.net/3ejqufp6/
- One
- Two
(I also added a min-width to the buttons as I couldn't stand the look of a ragged right-justified look to the buttons because of varying widths :) ) (我还向按钮添加了最小宽度,因为由于宽度的变化,我无法忍受按钮参差不齐的右对齐外观:))