简体   繁体   English

在jumbotron中垂直对齐glyphicons

[英]Vertically align glyphicons in a jumbotron

I have created a jumbotron and on the left I have some text on the left and some text with glyphicons to the right. 我创建了一个jumbotron,在左边我有一些文本在左边,一些文字在右边有glyphicons。 While the text on the left is vertically aligned to the middle, the text on the right along with the glyphicon is below the jumbotron. 虽然左侧的文字垂直对齐中间,但右侧的文字与字形一起位于超大屏幕下方

Here is the HTML code:- 这是HTML代码: -

<div class="jumbotron" >
        <div class="container-fluid text-left" style="padding-left:4px;">

            <p style="color:#f8921e">Text</p>

            <ul style="list-style-type:none ">
                <li><a class="glyph" href="#"> <span class="glyphicon glyphicon-cog"></span> Settings</a></li>
                <li><a class="glyph" href="#"> <span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
            </ul>
        </div>
     </div>

This is the CSS code:- 这是CSS代码: -

.jumbotron
    {
        width:100%;
        color: #f8921e;
        top:0;
        padding:20px;
        z-index:9;
        position:fixed;
        height:10%;
        background-color:black;

    }
.glyph
    {
        margin-right:20px;
        font-size:100%;
        color:#f8921e;
        float:right;
        padding-top:10px;
        display:block;
        text-align:center;

    }

Check this out. 看一下这个。 As when you write the logout and settings as unordered list, it becomes another block of code. 当您将注销和设置写为无序列表时,它将成为另一个代码块。 so it separates it from the text in p block. 所以它将它与p块中的文本分开。

https://jsfiddle.net/2ebc317L/ https://jsfiddle.net/2ebc317L/

 .jumbotron { width:100%; color: #f8921e; top:0; padding:20px; z-index:9; position:fixed; height:10%; background-color:black; } .glyph { margin-right:30px; font-size:100%; color:#f8921e; float:right; display:block; text-align:center; } 
 <div class="jumbotron" > <div class="container-fluid text-left" style="padding-left:4px;"> <p style="color:#f8921e">Text <a class="glyph" href="#"> <span class="glyphicon glyphicon-cog"></span> Settings</a> <a class="glyph" href="#"> <span class="glyphicon glyphicon-log-out"></span> Logout</a> </p> </div> </div> 

if you are trying to make navigation bar, i wouldnt suggest this way, because this will cause more and more problems as you add stuff. 如果你想制作导航栏,我不建议这样做,因为这会在你添加东西时引起越来越多的问题。 look for navigation bar in bootstrap, there are easier and better ways 在bootstrap中寻找导航栏,有更简单,更好的方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM