skip to Main Content

I have a problem and I couldn’t solve it. How to show social icons one line in collapsed menu? I added below code to my css file and nothing changed? Any idea? Thanks in advance

.navbar-right li {
    display: inline-block;
}

Here is my navbar code:

    <head runat="server">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" type="text/css" />
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.0/js.cookie.js" type="text/javascript"></script>
        </head>
     <div class="container">
      <nav class="navbar navbar-expand-lg navbar-light style="background-color: #ffffff;">
        <div class="d-flex flex-grow-1">
            <span class="w-100 d-lg-none d-block"></span>
            <a class="navbar-brand d-none d-lg-inline-block" href="https://testsite.com">
                <img src="images/logo.png" height="150" dir="ltr" alt="logo">
            
            </a>
            <a class="navbar-brand-two mx-auto d-lg-none d-inline-block" href="https://testsite.com">
                <img src="images/logo.png" height="100" alt="logo">
            </a>
            <div class="w-100 text-right">
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#myNavbar">
                    <span class="navbar-toggler-icon"></span>
                </button>
            </div>
        </div>
        <div class="collapse navbar-collapse flex-grow-1 text-center" id="myNavbar">
            <ul class="navbar-nav ml-auto flex-nowrap">
                <li class="nav-item">
                    <a href="https://testsite.com" class="nav-link m-2 menu-item">Home</a>
                </li>
                <li class="nav-item">
                    <a href="https://testsite.com/about" class="nav-link m-2 menu-item">About</a>
                </li>
            </ul>
             <ul class="nav navbar-nav navbar-right">
             <li><a href="https://www.facebook.com/" target="_blank" class="nav-link"><i class="fa fa-facebook fa-lg"></i></a></li>
             <li><a href="https://www.instagram.com/" target="_blank" class="nav-link"><i class="fa fa-instagram fa-lg"></i></a></li>
             <li><a href="https://twitter.com/" target="_blank" class="nav-link"><i class="fa fa-twitter fa-lg"></i></a></li></ul>
            </div>
        </div>
    </nav>

2

Answers


  1. you can just add bootstrap class names d-inline-flex flex-row to your ul tag with class navbar-nav navbar-right which your social icons are in it it will be like :

    <ul class="nav navbar-nav navbar-right d-inline-flex flex-row">
        <li><a href="https://www.facebook.com/" target="_blank" class="nav-link"><i class="fa fa-facebook fa-lg"></i></a></li>
        <li><a href="https://www.instagram.com/" target="_blank" class="nav-link"><i class="fa fa-instagram fa-lg"></i></a></li>
        <li><a href="https://twitter.com/" target="_blank" class="nav-link"><i class="fa fa-twitter fa-lg"></i></a></li></ul>
    

    if you need to you can even limit it by width like : d-sm-inline-flex and d-lg-flex for example

    or You can give display css : display : inline-flex; and flex-direction : row ; to your ul

     .navbar-right {
       display: inline-flex;
       flex-direction : row;
     }
    
    Login or Signup to reply.
  2. I will do this in your css class

    .navbar-right li {
        display: flex;
        flex-direction: row;
    }
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search