What is the best way to transform a CSS tab UI into a navigation bar?

Looking to transform these tabs into a fixed Bootstrap navigation bar at the bottom. Despite my efforts, they remain fixed at the top. How can I achieve this layout with the elements at my disposal? Thank you. You can view the incorrect page here. Tab "One" has its own ul but the content does not display correctly. The desired outcome is for Tab One to show "page 1" and "page 2".

The HTML body code looks like this:

$(document).ready(function() {
  $("#content").find("[id^='tab']").hide(); // Hide all content
  $("#tabs li:first").attr("id","current"); // Activate the first tab
  $("#content #tab1").fadeIn(); // Show first tab's content

  $('#tabs a').click(function(e) {
      e.preventDefault();
      if ($(this).closest("li").attr("id") == "current"){ //detection for current tab
       return;       
      }
      else{             
        $("#content").find("[id^='tab']").hide(); // Hide all content
        $("#tabs li").attr("id",""); //Reset id's
        $(this).parent().attr("id","current"); // Activate this
        $('#' + $(this).attr('name')).fadeIn(); // Show content for the current tab
      }
  });
});
#tabs {
  overflow: hidden;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

#tabs li {
  float: left;
  margin: 0 .5em 0 0;
}

#tabs a {
  position: relative;
  background: #ddd;
  background-image: linear-gradient(to bottom, #fff, #ddd);  
  padding: .7em 3.5em;
  float: left;
  text-decoration: none;
  color: #444;
  text-shadow: 0 1px 0 rgba(255,255,255,.8);
  border-radius: 5px 0 0 0;
  box-shadow: 0 2px 2px rgba(0,0,0,.4);
}

#tabs a:hover,
#tabs a:hover::after,
#tabs a:focus,
#tabs a:focus::after {
  background: #fff;
}

#tabs a:focus {
  outline: 0;
}

#tabs a::after {
  content:'';
  position:absolute;
  z-index: 1;
  top: 0;
  right: -.5em;  
  bottom: 0;
  width: 1em;
  background: #ddd;
  background-image: linear-gradient(to bottom, #fff, #ddd);  
  box-shadow: 2px 2px 2px rgba(0,0,0,.4);
  transform: skew(10deg);
  border-radius: 0 5px 0 0;  
}

#tabs #current a,
#tabs #current a::after {
  background: #fff;
  z-index: 3;
}

#content {
  background: #fff;
  padding: 2em;
  height: 220px;
  position: relative;
  z-index: 2; 
  border-radius: 0 5px 5px 5px;
  box-shadow: 0 -2px 3px -2px rgba(0, 0, 0, .5);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<nav class="navbar navbar-inverse fixed-bottom">

<nav>
  <div>
    <ul class="nav navbar-nav" id="tabs">
        <li class="active"><a href="#">Home</a></li>
        <li class="dropdown"><a href="#" name="tab1">One</a>
            <ul class="dropdown-menu">
                <li><a href="#">page 1</a></li>
                <li><a href="#">page 2</a></li>
            </ul>
        </li>
        <li><a href="#" name="tab2">Two</a></li>
        <li><a href="#" name="tab3">Three</a></li>
        <li><a href="#" name="tab4">Four</a></li>

    </ul>
  </div>
</nav>

Answer №1

Understanding the code provided above may be challenging, but you can experiment with using position: absolute; along with bottom: 0;

For instance:

#tabs {
  overflow: hidden;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
  position: absolute;
  bottom: 0;
}

Alternatively, adjust the positioning of the navbar itself:

.navbar {
    position: absolute;
    bottom: 0;
    width: 100%;
}

Answer №2

Modify the .navbar style by setting position: fixed, bottom: 0 and eliminating the bottom margin.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to display encoded URL image using <img src>

I have a scenario where I am dealing with a URL of an image link location that does not have a file extension like .jpg, but when accessed it displays the corresponding image. How can I output this URL in PHP? For instance, take the example of the reCAPTC ...

associating functions with various events that require arguments

I am working with two event listeners that trigger separate functions, but I believe it might be more efficient to have them trigger the same function instead. These event listeners are monitoring keystrokes and the mouse wheel. $(document).mousewheel(on ...

Having trouble with Javascript's JSON.stringify or PHP's json_decode?

I am attempting to send an array from JavaScript to PHP. JavaScript: var json = JSON.stringify(extraFields); url += "&json="+json; PHP: $json = json_decode($_GET['json'], true); foreach($json as $K=>$V){ echo "json".$K . "=" . $V ...

The v-for loop seems to only update the last element instead of all of them, which is incorrect

How can I ensure that all 3 page links in the nav are displayed in 3 languages of user choice? Initially, the language change works fine on page load. However, after clicking on a language change link once, only the last link's language changes instea ...

How come jQuery is retaining the original DOM element classes even after I have modified them using jQuery?

Here is the code snippet I am working on: $(".drop-down-arrow-open i").click(function(){ console.log("The click function for .drop-down-arrow-open is triggered even when it is closed"); let thisParent = $(this).closest(".projects-container").find(".need ...

Trouble with displaying THREE.js image on canvas

I have set up two different scenes and renders in my project. In addition, I have utilized Bootstrap 4 for the modal window functionality. One scene serves as the main display, while the other is displayed within the modal window. This is why I am employin ...

A flex container containing two divs each with a white-space:nowrap element set at 50% width

How can I create a parent div that contains two child divs, each with a width of 50% that adjusts based on content? The issue arises when one of the child divs has an h3 element with white-space:nowrap;, causing it to exceed the 50% width. I attempted to ...

I'm seeking guidance on how to efficiently showcase MySQL data using PHP and HTML

After creating a script to test output from my database, I encountered an issue. While the PHP portion works perfectly, extracting the data into an HTML div tag does not. Any suggestions on how to fix this would be greatly appreciated. Thank you. //Establ ...

Tips for modifying the font style of a Bootstrap form input using a custom font

While developing my website using Bootstrap 4, I encountered an issue with the custom font (GeosansLight) I applied to the entire website through the body's CSS attribute. The problem arose when the default Bootstrap form inputs appeared too light to ...

What is the best way to display numerous images on a cube face while also organizing them like a gallery wall?

I'm working on creating a unique gallery wall using three.js. Currently, I have successfully rendered an image on each side like this: My goal is to place multiple images on each wall instead of just one large image. Something similar to this concept ...

Retrieve: proper authentication credentials were not provided

Whenever I make a request, everything works fine and I receive the data: const get_players = async()=>{ const response = await fetch('http://127.0.0.1:8000/player_stats/api/players/') const data = await response.json() console. ...

The Challenge of Passing JavaScript Variables to SQL Queries in PHP Using AJAX

I am facing an issue with my PHP and MySQL setup. I have designed a PHP page with two sections positioned side by side. The left section displays a list of categories generated from a MySQL query, while the right section is intended to display subcategorie ...

JavaScript: Modify the dropdown class with a toggle option

Hi there, I'm currently facing a small issue and I could really use some assistance. I have a dropdown menu with two selection options - "green" and "blue", and I need to toggle a class based on the selected option. If you'd like to take a look, ...

Displaying Various Photos within bootstrap-table using Ajax Response

Upon receiving a response from an AJAX call, my task is to create a bootstrap-table with the data. The response contains an array with information about images, such as their paths and names. However, when trying to populate the bootstrap-table with this d ...

Issue encountered during Firebase deployment: Module '@babel/runtime/helpers/builtin/interopRequireDefault' not found

Struggling to deploy firebase functions and encountering multiple issues. During the deployment process, facing a babel error: Error: Cannot find module '@babel/runtime/helpers/builtin/interopRequireDefault' at Function.Module._resolveFilen ...

Adjust the product percentage discount color in WooCommerce

I am struggling to switch the box color of the percentage discount for each product from green to red. I tried modifying the function I found on Reddit, but I couldn't get it right and it caused a fatal error, crashing the entire website. Here is the ...

Implementing jquery into Angular 2 webpack project is essential as jQuery is necessary for Bootstrap's JavaScript to function properly

I am currently utilizing the angular-cli .net core starter. As I attempt to incorporate my own CSS and JavaScript files, I encounter the following error: An unhandled exception occurred while processing the request. Exception: Call to Node module fail ...

What is the reason that the for loop updates all indexes in Node.js?

Currently, I am working on a space battle program that involves nested arrays. In order to simulate fleet fighting, I have written the following code: //Roll a dice function const randomNumber = (number) => { return Math.floor(Math.random() * numbe ...

What is causing the added assets to not be saved in the hyperledger registry?

I have the application code below in my Hyperledger composer environment (My question pertains only to the RequestT transaction as I have not yet written the Respond transaction code): Data Model Code (.cto) /* * Defines a data model for chama transactio ...

Scrolling is endless with jCarousel - just press a button to keep moving even when you reach the first or

I seem to be experiencing a problem with jCarousel where, upon starting at the beginning, pressing the left button fails to scroll the carousel. The expected behavior is for the carousel to cycle to the end item when the left button is pressed while the f ...