Central arrow featured in dropdown menu

I've been attempting to style a dropdown menu, similar to the one located at this link, but I'm having trouble getting it to look just right.

The type of menu I'm striving for can be found here

Sample:

This is what I have managed to create so far!

http://jsfiddle.net/9ggfz0st/1/

@import url('http://getbootstrap.com/dist/css/bootstrap.css');
.dropdown-menu:before {
  position: absolute;
  top: -7px;
  left: 9px;
  display: inline-block;
  border-right: 7px solid transparent;
  border-bottom: 7px solid #ccc;
  border-left: 7px solid transparent;
  border-bottom-color: rgba(0, 0, 0, 0.2);
  content: '';
}
.dropdown-menu:after {
  position: absolute;
  top: -6px;
  left: 10px;
  display: inline-block;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #ffffff;
  border-left: 6px solid transparent;
  content: '';
}
<div class="dropdown">
  <a data-toggle="dropdown" href="#">Dropdown trigger</a>
  <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
    Account Settings<hr>Billing
  </ul>
</div>

I'm struggling to center the arrow in the middle of the menu and also apply a "drop down menu animation effect."

How do I go about centering the arrow perfectly?

Answer №1

To adjust the position of the arrow, simply modify the left attribute as shown below:

.dropdown-menu:before {
  position: absolute;
  top: -7px;
  left: 40%;
  display: inline-block;
  border-right: 7px solid transparent;
  border-bottom: 7px solid #ccc;
  border-left: 7px solid transparent;
  border-bottom-color: rgba(0, 0, 0, 0.2);
  content: '';
}

.dropdown-menu:after {
  position: absolute;
  top: -6px;
  left: 40%;
  display: inline-block;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #ffffff;
  border-left: 6px solid transparent;
  content: '';
}

JSFiddle

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

Tips on fetching the present value from the foreach loop with the help of jQuery in conjunction with CodeIgniter

Snippet of Code: <section class="panel"> <header class="panel-heading"> <a data-toggle="modal" data-target="#modal_edit" onclick="modal_edit('<?php echo base_url() ?>leave/save')" class="btn btn-default pull-r ...

Adding a stylesheet dynamically to the <head> tag using $routeProvider in AngularJS

Is there a way to load a specific CSS file only when a user visits the contact.html view on my AngularJS application or site? I came across this helpful answer that almost made sense to me How to include view/partial specific styling in AngularJS. The acce ...

Ways to remain on the same page even after submitting a form

I've been searching for a solution to my specific issue for days, but haven't had any luck. Can anyone provide assistance? I have a form on my website that is supposed to send an email when clicked, while also converting the div from a form to a ...

CSS tables are not properly recognizing the class values within the table

This is the CSS I am working with: table { margin: 10px 0 20px 0; width: 100%; text-align: center; } table th { color: #38A4FC; padding-top: 5px; background-color: #f9f9f9; width: 200px; height: 30px; border: 1px solid #d7d7d7; border-bottom: none; } ...

Limit the selected values to calculate a partial sum

Imagine two distinct classes called professor and student: professor.ts export class Professor { id: number name: string } student.ts import { Professor } from "./professor" export class Student { ...

What is the best way to smoothly transition between three images, each appearing in a randomized position and size?

Looking to add a dynamic div that fades in and out randomly with varying sizes and positions? You may have already tried displaying three images with fade-in and fade-out effects, but struggled with randomizing their placement and size. Check out this ex ...

Ways to extract data from a table in SQL utilizing jQuery, JSON, and AngularJS without relying on a web method

I need to retrieve table data from an SQL database. When the user clicks a button, I want the selected data table from the drop-down to be displayed. Although my drop-down is functioning correctly, I am unable to retrieve the selected table. public sta ...

Eliminate any line breaks that were generated by the div containing map information

I'm currently facing an issue with creating a map where I am adding pins using CSS coordinates. Every time I add a new pin div, it creates additional line breaks beneath the map. This could become problematic as I have around 130 pins to add in total. ...

Difficulty encountered with CORS problem-solving proxy

When conducting local testing between http://localhost:3002 (origin) and http://localhost:8080/configurator (server), I encountered a CORS issue. To address this, I decided to implement a proxy that would add the access-control-allow origins header to any ...

Remove an entire anchor tag from a contenteditable div with just one key press

I need help with my HTML code. Here is what I have: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Document</title> </head> <body> <div id="edi ...

The mobile menu functions correctly on Jfiddle but is not functioning on the local server

I was working on a responsive mobile menu and used a toggleClass function to open the menu. It's functioning correctly in Jfiddle and below, but every time I click the nav icon in the live preview within brackets, nothing happens. I even tried it in a ...

Creating a CSS Grid with Scroll Snap functionality to mimic an iPhone screen in HTML

I have created an iPhone simulator using HTML. It's in German, but I can provide a translation if needed: // JavaScript code for various functionalities related to the iPhone interface /* CSS styling for the iPhone interface */ <meta name="v ...

Optimizing mobile responsiveness for a portfolio landing page

Seeking advice on optimizing my site for mobile view. While the wide-screen monitor display is fine, issues arise when the browser size is reduced, causing sections to appear messy in mobile view. Any suggestions or tips would be greatly appreciated! Visi ...

Ways to trigger a function to update a variable

Within my function, I am utilizing a variable (link) that fetches the ID value from a specific row in my datatable. This value is then used in the Ajax URL when an element within the row is clicked. Subsequently, upon hover, a bootstrap popover is triggere ...

A guide to accurately accessing form data in Jquery Ajax requests

My beforeSend function is not working properly, as the background color does not change. I suspect it may be due to not correctly referencing the id variable posted from the form. Below is the relevant HTML and JS code: HTML <div id="rec<?php echo ...

Ensuring form field accuracy through server-side validation using Ajax - Mastering the art of Ajax

I am in need of implementing Ajax to validate my form fields, currently I have a javascript validation set up. Is it possible to reuse my existing javascript code and integrate Ajax for form validation? HTML Form <form method="post" action="ajax/valid ...

Add a class if the particular class is missing from the webpage

Seeking a solution in JS, I am facing a challenge in creating a series of elements with active states, each opening a caption below when clicked. Utilizing .addClass, .removeClass, and .toggleClass in combination, only one element can be active at a time. ...

CSS - Mistaken overlap - 3D Viewpoint

I've been playing around with CSS perspective to create a 3D card flip effect, but I'm running into an issue where the right-most cards are overlapping incorrectly when they flip. I've tried using Z-Index (knowing that it requires a position ...

Jquery causing Selenium to throw an error message "SCRIPT1004: Expected ';' " during execution

I am encountering an issue while trying to run jQuery in Selenium with the code below. Despite trying several different versions of jQuery min files, I continue to get the following error: Error : SCRIPT1004: Expected ';' Code : String mouseOv ...

jQuery sliding tabs

Hello everyone! I am currently on the search for a specific slider, and I'm hoping to find a good example of it similar to what is demonstrated HERE. Unfortunately, I do not know the official name of this particular type of slider, making it challengi ...