Home > Software engineering >  putting more items in bootstrap navbar
putting more items in bootstrap navbar

Time:11-19

I have a bootstrap navbar. I want to put signOut and welcome in the menu bar along with other menu items. Below is the screenshot of my navbar:

enter image description here

I want to put SignOut where the purple arrow is and right beneath "SignOut", I want to put "Welcome userName". I also want to move the logo and company/city name to extreeme left of the nav bar . How can I achieve that? Below is my code:

 <nav class="navbar navbar-expand-lg py-5 navbar-dark  shadow-sm " style="background-color: #264653;width:100%;" >
  <div class="container">


      <span class="navbar-brand" style="display:flex;">
        
            <img src="~/Images/InfoOrange.png" alt="ACR" width="70" height="70" class="d-inline-block align-middle mr-2" runat="server" />
      
       <span style="font-size:25px;color:white;"><span style="color:#e9c46a">test City</span><br />test company</span>

    </span>

    <button type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler"><span class="navbar-toggler-icon"></span></button>

    <div id="navbarSupportedContent" class="collapse navbar-collapse">
      <ul class="navbar-nav ml-auto">
       <%-- <li class="nav-item active"><a href="#" class="nav-link">Home <span class="sr-only">(current)</span></a></li>--%>
        <li class="nav-item dropdown nav-item active">
        <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Users
        </a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
          <a class="dropdown-item" href="#">Details</a>
          <a class="dropdown-item" href="Depatment.aspx">Department</a>
     
         <%-- <a class="dropdown-item" href="#">Sections</a>--%>
        </div>
      </li>
          <li>&nbsp;</li>

              <li class="nav-item dropdown nav-item active">
        <a class="nav-link dropdown-toggle" href="#" id="admindropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Admin
        </a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
          <a class="dropdown-item" href="NewBoxFolder.aspx">Box/Folder</a>
          <a class="dropdown-item" href="#">Configuration</a>

        </div>
      </li>
           <li>&nbsp;</li>
               <li class="nav-item dropdown nav-item active">
        <a class="nav-link dropdown-toggle" href="#" id="recordsDropDown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Records
        </a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
          <a class="dropdown-item" href="FileUpload.aspx">BlockChain Upload</a>
          <a class="dropdown-item" href="#">Verify</a>
          <a class="dropdown-item" href="DocReport.aspx">Report</a>
            <a class="dropdown-item" href="BucketList.aspx">S3 List</a>
        </div>
      </li>
    
    </div>
      <div>
          <ul>
                 
        <li class="nav-item" style="margin-right:5px" >
            <a class="nav-link px-5" href="<%= ResolveUrl("~/Pages/SignOut.aspx") %>">Sign Out</a>
        </li>
 
          </ul>
      </div>
  </div>
</nav>

any help will be gretly appreciated.

CodePudding user response:

You can contain this section with a class. In this instance I called it <div >. Then since your ul is a direct child of the parent you can use .sign > ul in your CSS to target that div. To get it in that position you can simply apply absolute positioning which allows you to define the area of the page. In your application, the top right. You can then add in your Welcome & Username area underneath as other unordered list items.

.sign > ul {
  position: absolute;
  top: 0;
  right: 0;
  list-style-type: none;
}
<div class="sign">
   <ul>
      <li class="nav-item" style="margin-right:5px" >
         <a class="nav-link px-5" href="<%= ResolveUrl("~/Pages/SignOut.aspx") %>">Sign Out</a>
      </li>
   </ul>
</div>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

  • Related