CSS bootstrap css中li中元素的右对齐

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20774856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 01:24:34  来源:igfitidea点击:

right alignment of element in li in bootstrap css

csstwitter-bootstrap

提问by zach57

I want to align livalues right most of the screen. but it does not appear.

我想li在屏幕的大部分位置对齐值。但它没有出现。

Codepan: http://codepen.io/

Codepan:http://codepen.io/

 <div class="navbar navbar-default navbar-fixed-top" role="navigation">
        <div class="container">   

    <ul class="nav navbar-nav navbar-right">
            <li><a href="../navbar-static-top/">Static top</a></li>
            <li><a href="../navbar-fixed-top/">Fixed top</a></li>
          </ul>

        </div>
      </div>

text-align:right;or align="right"does not help

text-align:right;align="right"没有帮助

采纳答案by thgaskell

You need to apply the text-align: rightto the anchor tags inside the list.

您需要将 应用于text-align: right列表中的锚标记。

CodePen

代码笔

CSS

CSS

.navbar-right li a {
  text-align: right;
}

回答by zach57

Try using the Bootstrap pull-right class inside of your ordered list tags like so:

尝试在有序列表标签中使用 Bootstrap pull-right 类,如下所示:

<ul class="pull-right">The text you want aligned to the right</ul>

回答by brouxhaha

Add text-align: right;to the ulinstead of the li

添加text-align: right;ul而不是li