Tips for adjusting Bootstrap's sub drop-down menu to the opposite side when hovering with the mouse

I'm working on a menu that has a dropdown feature, and here is a snippet of the code:

<li class="nav-item flyout">
    <a href="#" class="nav-link  dropdown-toggle nav_sp_clr {{#ifpage 'quicklink'}}active{{/ifpage}}">Quick Links</a>
          <ul class="flyout-content nav stacked ">

              <li class="flyout-alt my-flyout-alt nav-sub-menu">
                    <a href="jobs.html" target="_blank" >Jobs</a>
              </li>

              <li class="flyout-alt my-flyout-alt nav-sub-menu  ">
                    <a href="uploads/MBA-Workshop.pdf" download="">NIRF</a>
                      <ul class="flyout-content nav stacked ">
                        <li><a href=#>ENGINEERING</a></li>
                        <li><a href=#>MANAGEMENT</a></li>
                        <li><a href=#>OVERALL</a></l]i>
                      </ul>
             </li>    
          </ul>
</li>

Additionally, I have defined CSS classes to style the menu accordingly:

.flyout, .flyout-alt{
          position:relative;
       }
      .flyout-content{
          position:absolute;
          top:100%;
          left:-99999px;
       }
...

...

I've been trying to make a specific adjustment to the submenu behavior when hovering over the "NIRF" link. I want the submenu to appear on the left side instead of the right side. I've attempted using the left CSS property, but it's not achieving the desired outcome.

If anyone has insights or suggestions on how to achieve this effect, I would greatly appreciate the assistance!

Answer №1

Here are two solutions for your query:

  1. Include the following in your CSS:
 .my-flyout-alt:hover > .flyout-content{
        top: 20px ;
        left: -10% ;
 }

OR

  1. Replace
.flyout-alt:hover > .flyout-content

with

.flyout-alt:hover > .flyout-content{
    top:20px;
    left:-10%;
}

and adjust the left percentage according to your requirements.

Cheers!

Answer №2

.flyout-alt, .flyout{
          position:relative;
       }
.flyout-content{
          position:absolute;
          top:100%;
          left:-99999px;
       }
.staked li{
  width: 100%;
  display: flex;
}
.staked{
  display: flex;
  flex-direction: column;
 }
.flyout:hover > .flyout-content{
    left:0;
}

.flyout-alt > .flyout-content{
    top:0;
    left:-99999px;
}
.flyout-alt:hover > .flyout-content{
    top: 100%;
    left:0;
}
.flyout-content li a{
           color: #193e5a;
           display: block;
            background: #fff;
            text-align: center;
            font-size: 12px;
 }

.flyout-content li a:hover{
    background-color: #c3c3c3;
  }
.flyout-content li:hover{
          background-color: #c3c3c3;
 }
 .my-flyout-alt{
      color: #193e5a;    
 }
.nav-sub-menu{
         width: 135px;
 }
 .nav-sub-menu li{
  width: 135px;
 }
 .nav-sub-menu li:hover{
       width: 100%;
  }
   .my-flyout-alt ul{
           text-align: center;
            background: #fff;
   }
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<li class="nav-item flyout">
    <a href="#" class="nav-link  dropdown-toggle nav_sp_clr {{#ifpage 'quicklink'}}active{{/ifpage}}">Quick Links</a>
          <ul class="flyout-content nav stacked ">

              <li class="flyout-alt my-flyout-alt nav-sub-menu">
                    <a href="jobs.html" target="_blank" >Jobs</a>
              </li>

              <li class="flyout-alt my-flyout-alt nav-sub-menu  ">
                    <a href="uploads/MBA-Workshop.pdf" download="">NIRF</a>
                      <ul class="flyout-content nav stacked ">
                        <li><a href=#>ENGINEERING</a></li>
                        <li><a href=#>MANAGEMENT</a></li>
                        <li><a href=#>OVERALL</a></li>
                      </ul>
             </li>    
          </ul>
</li>

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

How can I extract the value of a JavaScript variable using jsoup in an HTML document?

<html> <script type="text/javascript"> var map = null; jQuery(function($) { L.marker([50.065407, 19.945104], {title: 'Cat'}) .bindPopup('<h3>Cat</h3> ...

How can I upload a folder with subfolders and keep the structure intact?

I'm working on a form that allows me to upload a folder containing both files and subfolders with more files inside. I managed to upload the folder successfully, but when I check my directory, all the files are in one folder without the subfolders. My ...

What is the best method for overlaying text on individual images in a slideshow?

Currently, I am delving into the world of jQuery, experimenting with various slideshows and attempting to incorporate text and effects. In my endeavors, I stumbled upon this codepen that served as an excellent template. However, when I tried adding text o ...

Utilizing Node.js and Express.js to Parse HTML Form Inputs

Having trouble extracting input from an HTML form and utilizing it in Node.js. Here is the HTML form being used: <form action="/myform" method="POST"> <input type="text" name="mytext" required / ...

Troubleshooting Paths with Angular's NgFor Directive

Within my Angular project, I have implemented a basic ngFor loop to display logo images. Here is a snippet of the code: <div *ngFor="let item of list" class="logo-wrapper"> <div class="customer-logo"> & ...

Sidebar collapse using Bootstrap

I have been working on creating a collapsible sidebar that pushes the content on the right, but I'm facing issues with responsiveness. When I display the sidebar, the content is getting compressed instead of pushed. I tried adding flex-shrink-0 to the ...

Sort PHP results by the initial letter of the name in a stylish manner

Hello, I am attempting to organize categories by the first letter and format them using ul and li elements. Here is my code: $Sql = "SELECT *, COUNT(Cup_Id) AS num FROM tabcup INNER JOIN tabcats ON tabcupom.Cat_Id = tabcats.Cat_Id ...

What’s the best method for enclosing a table and text within a div?

The following code snippet generates the following output: However, my desired outcome is this: When I remove <div>hello world</div>, the table fits perfectly within the outer div. But when I add text to the div along with the table, it doesn ...

How can I achieve rounded corners in Internet Explorer using JQuery?

I've tried using various plugins like curvycorners, DD_roundies, and behavior: url(ie-css3.htc);, but none of them seem to work properly. Can anyone suggest alternative methods for achieving rounded corners in IE? My website is designed to be resizabl ...

Entry is automatically added to the form as soon as the page is loaded

I am trying to create a form using PHP, but I want the script to only run after the submit button is pressed. Currently, it runs every time the page loads and overloads the box on the same page. Unfortunately, my knowledge of PHP is limited! Any help wou ...

What is the reason behind the effectiveness of this prime number verifier?

Take a look at this code snippet that effectively checks whether a number is prime: var num = parseInt(prompt("Enter a number:")); var result = "Prime"; for (var i = 2; i < num; i++) { if (num % i === 0) { result = "Not Prime"; break; } } ...

How can I reset a CSS position sticky element using JavaScript?

I have created a page where each section fills the entire screen and is styled using CSS position: sticky; to create a cool layered effect. Check it out here: https://codesandbox.io/s/ecstatic-khayyam-cgql1?fontsize=14&hidenavigation=1&theme=dark ...

The z-index of the React Apex Chart toolbar menu icon is too high. Is there a way to decrease it?

Is there a way to adjust the z-index value of the icons within React Apexchart's toolbar menu? Even when I position my element at a higher level, they remain on top of it. ...

Minify and group options available for asset managers specifically designed for traditional HTML websites

My primary focus is on working with the CakePHP framework and utilizing a fantastic plugin that minifies and groups selected assets into a single file, reducing the number of HTTP requests needed for the entire site. Currently, I am collaborating with des ...

carousel/slider must be accessible

I have been searching for hours and still cannot find the perfect carousel/slider that I need. The one at this link is close to what I want, but it becomes inaccessible when JavaScript is disabled in the browser. I am looking for a jquery infinite carous ...

Blog entries alternating between a pair of distinct hues

I want to create a design where each post container has a different color from the one next to it. Essentially, I would like the containers to alternate between two distinct colors. The left side shows how it currently appears, while the right side depict ...

I'm having trouble with getting my Bootstrap CSS and JS links to function properly

The paths for the Bootstrap CSS and JS files have been included in the code, but unfortunately, they are not working. Instead, I am getting the following errors in the console: GET http://127.0.0.1:5000/[https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist ...

The label is not displaying the specified font-family in CSS

Below is a snippet of code that I am having trouble with: testing some content Additionally, here is the CSS code for it: label { font-family: "Andale Mono"; } The issue I am facing is that no matter which font style I try to apply, it does not seem to ...

Utilizing Skeleton to create a cropped text button on an iPhone

I am currently using Skeleton for my simple CSS needs. While it works fine on desktop, I have noticed that on an iPhone, the text in my button gets cropped as shown in the picture. https://i.stack.imgur.com/EYo2P.png Below is the HTML code I'm using ...

Retrieve the class name from a CSS stylesheet

How can I extract all the CSS class names from a CSS file? This is what my CSS file looks like: p.juicy{ margin-left:40px; } p.csBody{ text-align:justify; } p.csCode{ font-family:"Lucida Console", Monaco, monospace; background-color:sil ...