Twitter Bootstrap: Align nav-tabs to bottom of div

前端 未结 3 1274
被撕碎了的回忆
被撕碎了的回忆 2021-01-13 14:04

I\'m building a website, and for the first time i am using the twitter bootstrap.

I\'m trying to align my menu to the bottom of my div. But for some reason i can\'t

相关标签:
3条回答
  • 2021-01-13 14:27

    Try this

    <ul class="nav nav-tabs navbar-bottom">
    
    0 讨论(0)
  • 2021-01-13 14:36

    In Bootstrap 4 you can use d-flex and align-items-end of the new flexbox utilities and place your logo right inside a <li> of your Nav <ul>:

    Example with left-side logo:

    <ul class="nav nav-tabs d-flex align-items-end">
        <li class="nav-item mr-auto">
            <a class="navbar-brand" href="#">
                <img src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-logo.png?v=9c558ec15d8a"
                    width="283" alt="Logo - Stack Overflow">
            </a>
        </li>
        <li class="nav-item">
            <a class="nav-link active" href="#">Item 1 <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#">Item 2</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#">Item 3</a>
        </li>
    </ul>
    
        
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">

    Example with right-side logo:

    <ul class="nav nav-tabs d-flex align-items-end">
        <li class="nav-item">
            <a class="nav-link active" href="#">Item 1 <span class="sr-only">(current)</span></a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#">Item 2</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#">Item 3</a>
        </li>
        <li class="nav-item ml-auto">
            <a class="navbar-brand" href="#">
                <img src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-logo.png?v=9c558ec15d8a"
                    width="283" alt="Logo - Stack Overflow">
            </a>
        </li>
    </ul>
    
        
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">

    0 讨论(0)
  • 2021-01-13 14:46

    You have to give the parent element a specific height. I would recommend doing this by adding an extra class, e.g. extraClass, to your <div class="col-md-8"> like this:

    <div class="row">
    <div class="col-md-4">
            <img class="img-responsive" src="img/logo.png" >
       </div>
    
       <div class="col-md-8 extraClass">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#"><span class="glyphicon glyphicon-home" style="color:#6d92a2"></span> Home</a></li>
            <li><a href="#"><span class="glyphicon glyphicon-check" style="color:#6d92a2"></span> Missie en Visie</a></li>
            <li><a href="#"><span class="glyphicon glyphicon-calendar" style="color:#6d92a2"></span> Activiteiten</a></li>
            <li><a href="#"><span class="glyphicon glyphicon-user" style="color:#6d92a2"></span> Lidmaatschap</a></li>
            <li><a href="#"><span class="glyphicon glyphicon-play-circle" style="color:#6d92a2"></span> Videozone</a></li>
            <li><a href="#"><span class="glyphicon glyphicon-map-marker" style="color:#6d92a2"></span> Contact</a></li>
       </ul>
    
       </div> <!-- nav tabs -->
    
    </div> <!-- row -->
    

    And the use this CSS:

    .extraClass {
        height: 122px; 
        position: relative;
    }
    
    .extraClass ul {
        position: absolute;
        bottom: 0;
    }
    
    0 讨论(0)
提交回复
热议问题