Vertical divider doesn't work in Bootstrap 3

前端 未结 6 2058
小蘑菇
小蘑菇 2021-02-01 00:16

I opened the Nav example which comes with the standard Bootstrap download (bootstrap-3.0.0\\examples\\navbar\\index.html) and added vertical dividers between two of the links.

相关标签:
6条回答
  • 2021-02-01 00:58

    as i also wanted that same thing in a project u can do something like

    HTML

    <div class="col-md-6"></div>
    <div class="divider-vertical"></div>
    <div class="col-md-5"></div>
    

    CSS

    .divider-vertical {
        height: 100px;                   /* any height */
        border-left: 1px solid gray;     /* right or left is the same */
        float: left;                     /* so BS grid doesn't break */
        opacity: 0.5;                    /* optional */
        margin: 0 15px;                  /* optional */
    }
    

    LESS

    .divider-vertical(@h:100, @opa:1, @mar:15) {
        height: unit(@h,px);             /* change it to rem,em,etc.. */
        border-left: 1px solid gray;
        float: left;
        opacity: @opa;
        margin: 0 unit(@mar,px);         /* change it to rem,em,etc.. */
    }
    
    0 讨论(0)
  • 2021-02-01 00:58

    may be this will help also:

    .navbar .divider-vertical {
        margin-top: 14px;
        height: 24px;
        border-left: 1px solid #f2f2f2;
        border-image: linear-gradient(to bottom, gray, rgba(0, 0, 0, 0)) 1 100%;
    }
    
    0 讨论(0)
  • 2021-02-01 01:03

    Here is some LESS for you, in case you customize the navbar:

    .navbar .divider-vertical {
        height: floor(@navbar-height - @navbar-margin-bottom);
        margin: floor(@navbar-margin-bottom / 2) 9px;
        border-left: 1px solid #f2f2f2;
        border-right: 1px solid #ffffff;
    }
    
    0 讨论(0)
  • 2021-02-01 01:06
    .divider-vertical {
    height: 50px;
    margin: 0 9px;
    border-left: 1px solid #F2F2F2;
    border-right: 1px solid #FFF;
    }
    

    and now you can use it

    <ul>
        <li class="divider-vertical"></li>
    </ul>
    
    0 讨论(0)
  • 2021-02-01 01:17

    I think this will bring it back using 3.0

    .navbar .divider-vertical {
        height: 50px;
        margin: 0 9px;
        border-right: 1px solid #ffffff;
        border-left: 1px solid #f2f2f2;
    }
    
    .navbar-inverse .divider-vertical {
        border-right-color: #222222;
        border-left-color: #111111;
    }
    
    @media (max-width: 767px) {
        .navbar-collapse .nav > .divider-vertical {
            display: none;
         }
    }
    
    0 讨论(0)
  • 2021-02-01 01:17

    I find using the pipe character with some top and bottom padding works well. Using a div with a border will require more CSS to vertically align it and get the horizontal spacing even with the other elements.

    CSS

    .divider-vertical {
        padding-top: 14px;
        padding-bottom: 14px;
    }
    

    HTML

    <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li class="divider-vertical">&#124;</li>
        <li><a href="#">Faq</a></li>
        <li class="divider-vertical">&#124;</li>
        <li><a href="#">News</a></li>
        <li class="divider-vertical">&#124;</li>
        <li><a href="#">Contact</a></li>
    </ul>
    
    0 讨论(0)
提交回复
热议问题