Aligning vertical pills to the right using Bootstrap framework

Here is the relevant code snippet that I am working with:

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<body>
  <div class="container-fluid">
    <div class="row content">
      <div class="col-lg-10">
        <div class="tab-content">
          <div id="AAA" class="tab-pane fade in active">
            <h2>AAA</h2>
            <p>
              Lorem ipsum dolor 
            </p>
          </div>


          <div id="BBB" class="tab-pane fade in">
            <h2>BBB</h2>
            <p>
              Lorem ipsum dolor 
            </p>
          </div>
        </div>
      </div>



      <div class="col-lg-2 sidenav" dir="rtl">
        <ul class="nav nav-pills nav-stacked">
          <li class="active"><a href="#AAA" data-toggle="tab" class="list-group-item">AAA</a></li>
          <li><a href="#BBB" data-toggle="tab" class="list-group-item">BBB</a></li>
        </ul>
      </div>
    </div>
  </div>      
</body>

I was able to achieve a layout where the pills are aligned vertically on the left side: pills stuck to the left. However, my desired outcome is for them to be aligned to the right, like this (as illustrated in mspaint): pills on the right.

I have tried numerous alignment options without success. Any guidance on how to achieve the desired layout would be greatly appreciated! Thank you!

Answer №1

To adjust the alignment of the ul, change the default padding from right to left. The CSS code provided is wrapped in a media query for right alignment on desktop, but this can be removed if needed.

Additionally, the code sets padding:0; for .sidenav and adds a border for visual alignment display.

@media (min-width:768px){
  .nav.nav-pills{
    padding-right:0;
    padding-left:40px;
  }
  .sidenav{
    border:1px solid black;
    padding:0 !important;
  }
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<body>
  <div class="container-fluid">
    <div class="row content">
      <div class="col-lg-10">
        <div class="tab-content">
          <div id="AAA" class="tab-pane fade in active">
            <h2>AAA</h2>
            <p>
              Lorem ipsum dolor 
            </p>
          </div>


          <div id="BBB" class="tab-pane fade in">
            <h2>BBB</h2>
            <p>
              Lorem ipsum dolor 
            </p>
          </div>
        </div>
      </div>



      <div class="col-lg-2 sidenav" dir="rtl">
        <ul class="nav nav-pills nav-stacked">
          <li class="active"><a href="#AAA" data-toggle="tab" class="list-group-item">AAA</a></li>
          <li><a href="#BBB" data-toggle="tab" class="list-group-item">BBB</a></li>
        </ul>
      </div>
    </div>
  </div>      
</body>

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

Searching dynamically using class names with JQuery

I am seeking to create a dynamic search input based on the class names within the span tags. However, I am struggling with displaying the class name that I have identified. My goal is to show the class names that match the entered value in the input on the ...

Unexpected CSS counter reset issue encountered within nested elements

Utilizing css counters for the formatting of certain wiki pages is a common practice that I implement by adding CSS directly to the wiki page. One particular use case involves numbering headers using counters. Below is a snippet of the code that demonstra ...

Ways to create a scrollable div with the help of Javascript

I am currently developing a web app on the Tizen platform. Within my HTML5 code, I have a div element with an image set as its background. In certain scenarios, I need to display random text within this div multiple times. The text can vary in size and ma ...

Introducing a pause in the function while rendering objects

After inserting setInterval into the code, it is causing all lasers to be delayed by one second. I am looking to have them fired in this order: - initially fire laser1 and laser2. - then take a 1-second break before firing another set of lasers, a ...

Identify the location of the mouse and activate a specific function based

Tracking the x-coordinate of the mouse is crucial in this scenario. When the mouse approaches a specific threshold (250px) towards the left edge of the window, it should trigger the function "openNav." The function should close when the mouse moves away fr ...

Conceal / Modify / Incorporate a picture

My ultimate goal is to have a hidden box and image that will be revealed based on the result of other functions. The box should change its background color, display an image, and switch images depending on the function called. I am facing two issues with ...

Tips for querying multiple elements that share a common ID and verifying if the input has been modified

I have a series of text inputs that share a common id prefix but differ slightly at the end. Whenever a user enters text in any of these input fields, I want to trigger a function. Currently, I have this functionality implemented with the following code: ...

Tips on how to transform an <input type="text"> element into a <tr> element using jquery

I am currently working on updating a row using jQuery Ajax. Whenever the Edit button is clicked, it switches the <tr> element to <input type='text'>. I have utilized the .Change method which triggers successfully, but my goal is to r ...

Exploring the capabilities of soup.find() for achieving partial matches

I've been struggling to find an answer to this issue elsewhere, so I'm turning to this code: soup.find(text="Dimensions").find_next().text to extract the text after "Dimensions". The problem arises on the website I'm scraping beca ...

Effortlessly adjust item width in CSS Grid

I am currently utilizing CSS Grid to showcase various tags. If a tag happens to be quite large, with a width exceeding 150px, I would ideally like that specific item to expand across multiple columns as necessary. For instance, in the visual representation ...

Tips on updating the content of an HTML element dynamically when it is already being populated using *ngFor

I have created an HTML component that utilizes *ngFor to dynamically generate HTML elements. This results in a total of 3 tags being generated when the code is run. I have included data such as subject in the component file which updates dynamically, how ...

ng-click event not firing after $compile in AngularJS

I'm struggling to get my dynamic HTML elements generated from an AngularJS controller to trigger a function using ng-click. Even after using $compile, the function is not being called. Check out my JS code: var accountApp = angular.module('acco ...

Tips for ensuring Marketo forms are responsive when integrated into a WordPress website

We are currently using Wordpress for our responsive website. Within the site, we have integrated Marketo forms (a marketing automation system) with custom CSS for styling. The issue we are facing is that while the forms appear fine on desktops, they cause ...

Strategies for positioning a fixed div at the bottom of another div

I'm in the process of creating a digital restaurant menu... I decided to format it as a popup, situated within a fixed container on top of a gray transparent overlay. However, with a large number of dishes, the content exceeds the size of the containe ...

Incorporate a section of text to flow around a floated image within a paragraph

How can I achieve the text wrapping above an image similar to the layout in the sunflower picture? I have tried using relative positioning and adjusting the top property, but it doesn't allow the text to wrap around the image. Setting the position to ...

Troubleshooting regex validation issues in a JSFiddle form

Link to JSFiddle I encountered an issue with JSFiddle and I am having trouble figuring out the root cause. My aim is to validate an input using a regex pattern for a person's name. $("document").ready(function() { function validateForm() { var ...

Tips for Placing a Div in a Precise Location

I'm currently working with Bootstrap and I'm attempting to replicate a layout similar to the one used by Twitter, as shown in the screenshot below. The specific part I'm struggling with is where the profile picture is located. I want to add ...

Modify the paragraph's class upon clicking the radio button

I have been struggling with changing the color of <p> based on the radio button selected using two classes, red and blue. However, for some reason, it's not working as expected. If anyone has any insights or suggestions on how to fix this issue ...

Effortlessly implement CSS styling in a scoped shadow element with Vue3

I am facing an issue with applying styles to an anchor element in my code. Below is a snippet of the code: <template> <custom-button> #shadow-root (open) <a href="#"></a> <other-custom></other-c ...

Is it possible to modify the inactive color of just one radio button in Framework7?

Is there a way to change the inactive color of only one radio button in Framework7? I am aware that using the CSS variable --f7-radio-inactive-color allows me to set the inactive color for all radio buttons. However, I specifically want to modify the inac ...