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

Easy steps for aligning text with shiny html

Looking at the code below, I was able to successfully align the bullet-point text in the popover when hovering over the information circle. However, I am still struggling to justify-align its header right above it, as seen in this image. When I remove the ...

Unlock the power of Bootstrap CDN with these easy steps!

I am currently trying to incorporate a CDN for Bootstrap in order to enhance the performance of my website. Surprisingly, directly referencing the CSS works perfectly fine but using the CDN does not. Could someone provide me with guidance on how to resolv ...

The innovative technique of using pure CSS to secure the bottom edge of a div to the viewport

Is there a way to keep two container divs positioned x pixels from the bottom of the viewport without using position absolute|fixed? I want them to remain as position: relative for proper DOM flow. Searching for a CSS-only solution that works in IE7+. Mos ...

The hamburger icon is not visible on smaller screens when using the Bootstrap 5 navbar

'The stylesheets for Bootstrap CSS and JS have been included in the file. The content shows up fine with default colors, but not when I customize them.' ''' <li class="nav-item"> <a class= ...

The process of overriding CSS applied through JavaScript

I am using a third-party multi-select dropdown. Similar to Select2, the multi-select dropdown is created using JQuery with select2.min.js and the width of the dropdown is automatically calculated. Is there any way to apply static width to it, as I believe ...

Having trouble with jQuery's recursive animation functionality

I have developed a function to scroll multiple images horizontally in the header of my website. Inside my header, I have implemented code that looks like this: <div class='images'> <!-- this div is 150% wide with overflow hidden --> ...

Tips for transferring this text to a new line

I have come across this text that needs to be moved to a new line, This is its current appearance, Here is how I want it to look: HTML code snippet: <div id="content"> <div id="header"> <p> <img class="header-im ...

When the form is submitted, the value is not refreshed if the button is exited

I need to have a form where the save button is positioned outside of the form elements. However, when I move it elsewhere, the form does not refresh. <form ng-submit="save()" action="" name="addInv" novalidate> <div class="col-md-10 ...

Clicking on the href=#div will cause the page to smoothly scroll down

Whenever I click on the links in my navigation bar, the page automatically scrolls down. How can I resolve this issue? I have a navigation bar containing a list of links. Below is the HTML code: <ul> <li><a href="page.html#1">menu item ...

What are the steps to troubleshoot CSS issues in NextJS?

Currently, I am encountering challenges while trying to integrate markdown with CSS. The problem I am facing has been replicated in the link provided: https://codesandbox.io/s/react-quilljsbasic-forked-3rcxw?file=/src/App.js ...

The final item in the navigation bar is off-center

After centering all text within the li tags, the last one appears to be slightly closer to the bottom. Below is the code snippet along with an image: *{ margin:0; padding:0; box-sizing:border-box} #hamburgerClick{ displa ...

Enhance the clarity of content within an IFrame by sharpening the focus on

I recently developed an iframe to open a chat site I built using React.js and Tailwind. The iframe is loaded dynamically on the website through javascript. However, I noticed that when I click on the input field inside the iframe, the content appears blurr ...

animation of leaping to a specific element

I am currently working on a sidebar with links that have a hover effect to add a bullet. However, I want the bullet to smoothly follow the cursor's movement along the y-axis within the sidebar instead of jumping between the links. How can I achieve th ...

Accessing a specific segment of HTML using Java

Attempting to navigate through a bunch of HTML, I'm aiming to isolate specific sections. I'm specifically looking to retrieve 'THISISTHEBITIWANT' from the following HTML code. <li class="aClass"> <a href="example/THISISTHEB ...

Automatically navigate through form fields using jQuery when pasting data

Enhancing the form filling experience by allowing users to prepare a text file in advance and simply copy/paste it into the form for quick submission. Integration of a feature that automatically moves to the next input field when a tab or newline character ...

What methods can be used to modify the appearance of the cursor depending on its position?

Is there a way to change the cursor to a left arrow when on the left half of the screen and switch it to a right arrow when on the right half, using JavaScript? I am trying to achieve something similar to what is shown on this website. I attempted to acco ...

Facing issues with vertical Tab display in Bootstrap using Vue.js - unexpected results

Below is the script I am working with: <vue-tabs class="row" direction="vertical" value="Description"> <div v-for="(siteParts, index) in sitePartLine"> <v-tab :title="sitePartLine[index].serial_no" v-if="sitePartLine[i ...

Create a new div element in your HTML structure that is not currently defined in your Sass/CSS

Currently, I am developing a React Component that includes a DatePicker feature using PrimeReact's Calendar component. I have a specific requirement to display an arrow on top of the datepicker when it pops up. You can view the desired layout in the ...

Steps to make a sub Post or page on WordPress

Seeking to add sub posts within my website's main posts. The URL structure for the main post will be: site.com/post-title I envision sub posts following this format: site.com/post-title/subpost1 site.com/post-title/subpost2 site.com/post-title/ ...

How to perfectly position multiple tables using CSS

I am relatively new to the world of HTML and CSS. I have successfully created several tables, but now I am struggling to display them all on a single line within a designated box. Despite my best efforts, I have not been able to achieve the desired result. ...