Bootstrap: .stacked-navigation

Currently working on an app utilizing Bootstrap v3.3.5. I have set up a navigation bar and now looking to implement two different views.

The first view is intended for tablets and computers, featuring icons alongside the menu item names without any dropdown functionality.

The second view caters to phones with icons and a dropdown-menu-right feature. How can I create a responsive sidebar that adapts to these requirements?

Any assistance would be greatly appreciated.

Check out the Bootstrap .nav-stacked image here

<!DOCTYPE HTML>
<html>
<script src="js/bootstrap.js"></script>
<head>
<link type="text/css" rel="stylesheet" href="css/bootstrap.css">
</head>


<body>
<ul class="nav nav-pills nav-stacked" id="pills-first">
<li><a href="#"><span class="glyphicon glyphicon-glass"></span>  Glas</a></li>

<li><a href="#" data-target="#submenu1"><span class="glyphicon glyphicon-music"></span> Music</a></li>
<ul id="submenu1">
<li><a href="#"><span class="glyphicon glyphicon-volume-off"></span> Volume off</a></li>
<li><a href="#"><span class="glyphicon glyphicon-volume-down"></span> Volume down</a></li>
<li><a href="#"><span class="glyphicon glyphicon-volume-up"></span> Volume up</a></li>
</ul>
       

<li><a href="#"><span class="glyphicon glyphicon-search"></span> Search</a></li>
</ul>
  </div>
</body>
</html>

Answer №1

To achieve the desired outcome, a mix of media queries and visible/hidden classes can be utilized effectively.

In order to create two versions of the Music link - one for mobile dropdown toggle and the other as a regular link for tablet/desktop - "hidden-xs" and "visible-xs" classes were employed to display the appropriate version based on the device screen size.

For adjusting the dropdown navigation to be displayed to the side on mobile devices, CSS media queries were applied:

@media(max-width:767px) {
    li a[data-target="#submenu1"], #submenu1 {
        float:left;
    }
    #submenu1 {
        padding-left: 0;
        margin-left: -5px;
        list-style: none
    }
    #submenu1>li {
        display: inline-block;
        padding-right: 5px;
        padding-left: 5px
    }
    .dropdown {
        display:inline-block;
    }
    #submenu1 {
        left:100%;
        top:0;
        width:250px;
        border:0;
        box-shadow:none;
        margin:0;
    }
}

Additionally, to ensure that the music dropdown is always visible on tablet/desktop screens, the following CSS was included:

@media(min-width:7678px) {
    .dropdown-menu {
        position:relative;
        display:block;
        float:none;
    }
}

Further customization may be needed, but an example showcasing the desired result can be viewed here: https://jsfiddle.net/partypete25/8Lrr88y5/

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

Retrieve the date from 7 days ago and display it in the format "2015-06-23" using JQuery/JavaScript

Looking to retrieve last week's date in the following format: "2015-06-23", as opposed to "2015-06-16". JavaScript: t = new Date(); // Tue Jun 23 2015 21:00:47 GMT-0700 (PDT) t.toISOString(); // "2015-06-24T04:00:47.955Z" The current date format i ...

At times, an InvalidArgumentError occurs stating: "The 'handle' parameter must be a string."

I have incorporated 'React-google-login' into my React project and now I am working on an automated test to make sure it functions correctly. try { await driver.get("http://localhost:3000/"); await driver.wait(until.elementLocated(By.xpath(` ...

Is there any truth to the idea that storing in the session cache can prevent frequent executions of the backend code?

As I work on creating a website using the Zend Framework, I encounter a situation where I am utilizing AJAX to save store ratings in my database. One crucial piece of information required for this process is the key that identifies the specific store for w ...

Conceal a text field depending on the value within a hidden field that was populated automatically by a JavaScript function

I encountered a peculiar issue recently. I have a form with a field for entering card numbers. There is a JavaScript code that automatically detects the type of card (such as Maestro, Visa, etc.) based on the entered number. If the detected card type is &a ...

What is the method for retrieving a specific value following the submission of an AngularJS form?

Here is how my form begins: <!-- form --> <form ng-submit="form.submit()" class="form-horizontal" role="form" style="margin-top: 15px;"> <div class="form-group"> <label for="inputUrl" class="col-sm- ...

Focusing on a specific input category inside a div container

Struggling to customize the appearance of the last input type within the Jetpack plugin in WordPress. I have experimented with the following CSS: #subscribe-submit > input[type="submit"]::last-of-type { #subscribe-submit > input[type="submit"]:nth- ...

Please disable zoom functionality on the website specifically for Android devices

Is there a way to disable the zoom feature on our website specifically for Android phones/devices without affecting iPhones? Perhaps targeting the Chrome browser on Android would be sufficient, but we should also verify the mobile screen size. ...

How to output a string in jQuery if it includes a certain character?

I need to extract all strings that include a specific word within them, like this: <div> <div> <span> <h3>In Paris (Mark Bartels) worked for about 50 years.</h3> </span> </div> ...

Steps for executing a function once an AJAX call is completed inside an iframe

I am facing a challenge with extracting a variable value called useableData from an iframe back to the parent page. The page and iframe are both on the same domain. Inside the iframe, there is an AJAX call that populates some input fields with data, and I ...

Pattern matching tool for identifying React components with an unlimited number of properties

Currently diving into MDX and experimenting with Regex to extract details on React components from Markdown files. The regex pattern I'm aiming for should: Detect all types of React components This includes identifying the opening tag <Component ...

Maximizing the use of default top positioning for absolutely positioned elements

After observing that an element with position:absolute can have its default top value determined based on its immediate parent's position, regardless of whether it is set to relative or not, BoltClock explained that in such cases, it remains in a stat ...

Extract the ID data from the template model form and utilize Django's AJAX to showcase the corresponding information fetched from the database

Currently, my view is set up to display the latest ID and its corresponding data from the database. You can see a sample form by following this link: My goal is to take the displayed ID, send it to my view, increment it, and then show the data related to ...

Is there a way to prevent the imported JQuery from causing issues with current code implementations?

Being a novice developer in Html/Javascript/CSS/Jquery coding, I recently encountered an issue while integrating Jquery into my project. When I imported Jquery, the styling of simple buttons went haywire. Jquery worked perfectly fine when using its classes ...

How to Properly Adjust the Material UI CircularProgress Size

Is there a way to display the Material UI CircularProgress component at a size that nearly fills the parent div, which has an unknown size? Ideally, I want the size to be around 0.8 * min(parent_height, parent_width). I've experimented with adjusting ...

Transforming localhost into a server name in a Node.js environment

Recently I began working on full stack development. I have a physical server and I want to upload my code to it so I can run the NodeJS server from there. This way, when people try to access my site, they will use or instead of localhost:port, which on ...

The payload transmitted from JavaScript to Django Views is devoid of any content

I'm currently working on sending data from JavaScript to Django using ajax. Below is the code snippet I am using for this: var json_name = {'name': 123} $.ajax({ method: 'POST', url: ...

Exploring the Terrain: Troubleshooting Meteor CSS with Twitter Bootstrap

Recently, I have encountered an issue that perplexes me - I am unable to debug less code in my meteor app when the twbs:boostrap package is present. Interestingly, everything works fine when I remove it, but as soon as I add it back, the CSS seems to be co ...

The perplexing behavior of RxJS Observables with Mongo Cursors

Recently, I've been working on converting a mongo cursor into an observable using my own RxJS implementation. Despite finding numerous solutions online, I wanted to challenge myself by creating one from scratch. I would greatly appreciate it if someo ...

The div is leaving the responsive bootstrap gallery

I'm experiencing an issue with my gallery overflowing the parent div and not staying sorted in all screen sizes. Here's a screenshot along with a snippet of the code: https://i.sstatic.net/mKRtZ.jpg <div id="gallery" class="container-fluid" ...

"Invalid function reference" when a function is used as a parameter within another function

My knowledge in NodeJS and JS is limited, so please keep that in mind. Recently, I've been experimenting with a radix trie module called Merkle-Patricia-Tree, which led me into a complex situation when utilizing a module similar to Google's level ...