Place the cursor on the dropdown menu in Bootstrap 4

Is there a way to move the arrow outside of the dropdown menu? I am currently encountering this issue.

https://i.sstatic.net/ozysw.png

I want my layout to look like this, with the arrow positioned similarly to the dropdown menu on Github.

https://i.sstatic.net/6XoLf.png

This is the code for my dropdown menu:

<div class="container">
  <div class="row">
    <div class="col-md pl-4 user-dropdown">
      <div class="dropdown btn-group">
        <a class="navbar-brand dropdown-toggle" href="#" id="bd-versions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          <i class="fas fa-user"></i>
        </a>
        <ul class="dropdown-menu text-center mt-2">
          <span><i class="caret-up fas fa-caret-up ml-2"></i></span>
          <li>
            <a href="{{ route('login') }}">
              <button type="button" class="btn btn-warning text-dark">Sign-in now</button>
            </a>
          </li>
          <div class="dropdown-divider"></div>
          <li>
            <h6>Don't have an account?</h6>
            <a href="{{ route('register') }}">Sign-up here</a>
          </li>
        </ul>
      </div>
    </div>
    <div class="col-md">
      <span><a class="navbar-brand" href="#"><i class="fas fa-shopping-cart"></i></a></span>
    </div>
    <div class="col-md">
      <span><a class="navbar-brand" href="#"><i class="fas fa-heart"></i></a></span>
    </div>
  </div>
</div>

Answer №1

.container {
  background-color: black;
  height: 100%;
}

.user-dropdown .dropdown-menu {
  left: 0;
  transform: translateX(-50%) !important;
  top: 100% !important;
}

.arrow-up {
  width: 0px;
  height: 0px;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 10px solid #FFFFFF;
  margin: 0 0 15px 0;
  position: absolute;
  top: -9px;
  right: 0;
}
<head>

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>

<body>
  <div class="container">
    <div class="row">
      <div class="col-md pl-4 user-dropdown">
        <div class="dropdown">
          <a class="navbar-brand dropdown-toggle" href="#" id="bd-versions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            B<i class="fas fa-user"></i>
          </a>
          <div class="dropdown-menu text-center mt-2">
            <div class="arrow-up"></div>
            <a href="{{ route('login') }}">
              <button type="button" class="btn btn-warning text-dark">Sign-in now</button>
            </a>
            <div class="dropdown-divider"></div>
            <h6>Don't have an account?</h6>
            <a href="{{ route('register') }}">Sign-up here</a>
          </div>
        </div>
      </div>
      <div class="col-md">
        <span><a class="navbar-brand" href="#"><i class="fas fa-shopping-cart"></i></a></span>
      </div>
      <div class="col-md">
        <span><a class="navbar-brand" href="#"><i class="fas fa-heart"></i></a></span>
      </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

Steps for creating a transparent Bootstrap navbar:1. Start by creating

I have Bootstrap HTML code for a navbar <!--Navbar--> <nav class="navbar navbar-expand-lg navbar-dark bg-dark"> <img class="logo" alt="Brand" src="images/1.png"> <a class="navbar-brand" href="Homepage.jsp">Car ...

What is the best way to activate a function once two HTML elements have been completed?

In my HTML code, I have integrated a datepicker and a select element. Currently, there is a button linked to the method checkAvailability() <div class ="d-flex flex-row bd-highlight mb-3"> <div class = "form-froup row"> ...

The Ladda spin animation continues spinning for an additional second after the stop() function is called

I employ the ladda spinner in this manner: var l = Ladda.create(document.getElementById('ladda-test')); l.start(); l.stop(); console.log('ladda is stoped'); The issue I am facing is that following the execution of l.stop(), the animat ...

Utilizing jQuery for leveraging nested functions to efficiently parse JSON data with Handlebars templates

<div id="app"></div> <script> compileTemplate = function (source) { var template = Handlebars.compile(source); function insertData(id, data, tpl) { $(id).html(tpl(data)); } $.get('./templates/life.hbs', function( ...

Combine a frame with a photo side by side

When I put a frame and a picture together, my photo is not fully displayed. In each size (such as mobile phone, larger size, and medium size), only a part of the image is shown. Can anyone help me with this issue? Here is my HTML markup: <!-- about sec ...

The property mentioned was attempted to be accessed during the rendering process, however it is not defined on the instance

I am currently facing four main errors that I need to resolve while working with Vue 3: https://i.sstatic.net/23ir7.png Despite everything else working correctly, my code seems to have issues specifically with user inputs. //############--contact.js-- ...

for each iteration to a hyperlink

Having an issue with my web site. I've created two PHP files, where the first one contains variables and an array, and the second one has another array with URL addresses as variables. Now I'm trying to figure out if I can do something like this: ...

Having an issue where the Jquery clone function is only duplicating the content once. Looking to

I'm currently working on existing HTML table code. My goal is to copy the text from the 'th' header rows and paste them inside the corresponding td cells for each subsequent row. While I have successfully managed to copy the header row, it o ...

Item template with dynamic content for pagination directive

My current implementation includes a paginator directive that displays items from an array: .directive('paginator', function() { restrict: 'A', template: '<div ng-repeat="item in items">' ...

Dual-tone border design

Is it possible to create a double border effect with one color on top and another color on the bottom using CSS? I'm trying to recreate an image with a border that has two different colors on different parts of the width using only CSS: ...

Disable the 'bouncy scrolling' feature for mobile devices

Is there a way to prevent the bouncy scrolling behavior on mobile devices? For example, when there is no content below to scroll, but you can still scroll up and then it bounces back when released. Here is my HTML structure: <html> <body> ...

Encountering difficulties trying to integrate bootstrap4-toggle into Angular 8

Recently diving into Angular, I decided to enhance my project by importing bootstrap4-toggle from the following source: in order to incorporate a stylish toggle checkbox. After running npm install and confirming the presence of the package in package.json ...

Containers do not line up properly with each other. Adjusting the width leads to unexpected consequences

As someone who is new to HTML and CSS, I am facing a challenge with aligning the items within a navigation bar on my website. The list serves as a navigation bar and is contained inside the "inner header" div. While I was able to align the entire "nav" con ...

Change the class when the scroll reaches the same letter block while moving up or down

Within this div, there is a horizontal list displaying all the alphabets. Below the list, there are blocks of names starting with each alphabet, with the header of each block matching the respective alphabet. I am looking to add a class to the div contain ...

Using PHP to showcase a variety of checkbox fields

I currently have a form with various checkbox fields. While I was able to display the values using a foreach loop, I am curious if it's possible to display them based on how they were selected. Below is the code in question: <html> <head> ...

Implement CSS styling on a single page by utilizing SCSS in conjunction with ReactJS and Redux

I'm currently working with ReactJS and Redux, utilizing SCSS for styling. Currently, my path is located at http://localhost:3000/login. I need to include the following on this page: html:{ overflow:hidden} However, on other pages, I want to remove th ...

Problem with image dimensions in Owl Carousel

I have been working on customizing a WordPress theme that originally utilized a bootstrap template. However, I am currently facing an issue with the slider designed for the testimonials section. To create the slider, I decided to use Owl Carousel and incl ...

Is it Possible to Load Images Without Using Javascript?

When I hover over certain links on my HTML pages, large images are displayed but take a while to load. I prefer not to use JavaScript to preload the images. Are there any alternative solutions available? ...

Swap out a portion of HTML content with the value from an input using JavaScript

I am currently working on updating a section of the header based on user input from a text field. If a user enters their zip code, the message will dynamically change to: "GREAT NEWS! WE HAVE A LOCATION IN 12345". <h4>GREAT NEWS! WE HAVE A LOCATIO ...

jQuery and ajax method are failing to insert data into the database

I am having trouble inserting data into the database using jQuery and Ajax. Can someone please assist me in figuring out if I'm doing something wrong? Here is the code snippet: form.html <!DOCTYPE html> <html> <head> & ...