Display a triangle underneath the chosen menu option

How can I display a small triangle below the selected menu item, similar to my tag box? I have tried various methods without success. You can view my attempts at this link. Any suggestions on how to achieve this? Thank you!

nav {
    float: right;
    margin: 20px auto;
    width: 100%;
}
nav ul {
    margin-right: -4px;
    margin-left: 5px;
    text-align: right;
    }
nav ul li {
    display: inline-block;
    margin-right: -4px;
    margin-left: 5px;
    vertical-align: top;
}
nav a {
    padding: 4px 8px;
    text-decoration: none;
    color: rgba(255,255,255,1) !important ; 
    background: rgba(0,0,0,0.25);
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 14px;
    font-weight: 400;

}


nav a:hover {
    background: rgba(0,0,0,0.35) !important ; 
}
.activeNav {
    background: rgba(0,0,0,0.35) !important ; 
}
nav ul li ul {
    position: absolute;
    display: block;
    margin-top: 5px;

    background: none;
    padding-top: 5px
}
nav ul li ul li {
    display: block;
    float: none;
    margin: 0;
    padding: 0
}
nav ul li ul li a {
    display: block;
    text-align: left;
    color: rgba(255,255,255,0.9) !important ; 
    text-shadow: 0 1px rgba(0,0,0,0.33) !important ; 
    padding: 10px
}
nav ul li ul li a:hover {
    background: rgba(20,150,220,0.5) !important ; 
    color: white;
    text-shadow: 0 1px rgba(0,0,0,0.5)
}
.hover a {
    display: block;
}
.hover span {
    color: rgba(255,255,255,0.9);
    background: rgba(20,150,220,0.5);
    border-radius: 5px;
    position: absolute;
    display: block;
    margin: 5px 0 0 -57px;
    padding: 10px;
    font-size: 13px;
    font-weight: 300;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-align: center;
    cursor: default;
}

li.selected a{
    border-bottom: 1px solid rgba(16,65,145,0.9);

}


li.selected a:after {
  top: 100%;
  left: 50%;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
  border-color: rgba(136, 183, 213, 0);
  border-top-color: #3A7CDB;
  border-width: 10px;
  margin-left: -10px;
}


.tagbox {
  top: -10px;
  left: 60%;
  position: absolute;
  background-color: #3A7CDB;
    background-image: linear-gradient(to bottom, #518CDE, #3A7CDB);
    background-repeat: repeat-x;
  padding: 10px 20px;
  width: 250px;
  margin-left: 0px;
  text-align: center;
  color: #fff;
        margin-top:140px;

}

.tagbox:after {
  top: 100%;
  left: 50%;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
  border-color: rgba(136, 183, 213, 0);
  border-top-color: #3A7CDB;
  border-width: 10px;
  margin-left: -10px;
}

Answer №1

Check out the latest version of your fiddle here - http://jsfiddle.net/7zRVU/4/

You've made progress, but to finalize it, simply add a "position:relative;" to your "selected" class. This will allow the arrow to be positioned absolutely with it. Then adjust the position of the arrow to "top: height of the selected item".

.selected {
    position: relative;
}

li.selected a:after {
  top: 23px;
  left: 50%;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
  border-color: rgba(136, 183, 213, 0);
  border-top-color: #3A7CDB;
  border-width: 10px;
  margin-left: -10px;
}

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 about this: "Is it possible for the accordion to open when clicked and show

Screenshot illustrating the issue I need assistance with implementing a hover preview for the contents of the accordion, followed by keeping it open upon clicking. The codepen link is provided below for reference: Visit the codepen here <script src=&q ...

What is the best way to guide a user to a specific page based on the choice they made after submitting a form?

My form includes a list of 6 options where users can only select one. After submitting the form, I want to redirect them to a specific page based on their selection. For example, I have the following 3 options: Facebook Youtube Twitter If a user selects ...

The background property does not support linear-gradient in CSS

I am currently working on creating a tree structure using the vue-orgchart library (link) Everything is functioning correctly, but I am interested in changing the green background color of the node (ignoring the white portion). https://i.sstatic.net/EEcd ...

What can I do to stop hidden HTML tags from loading on my page? Is it possible to completely remove them from the page

I previously inquired about this question but did not receive a satisfactory answer. Here are the input fields I am working with: <form method ="post" action="select.php"> <input id="nol" style="width: 350px;" type="text" name="searchdisease" pl ...

What is the best way to adjust the margins of my div based on the width of the webpage?

I have a website where I use two columns with modules to display information like this: https://i.sstatic.net/Jp97V.png However, I work on vertical monitors and when I switch to a more landscape format, the layout looks like this: https://i.sstatic.net/D ...

Ways to dynamically modify the CSS attributes of a webpage during the page load event

I'm looking to incorporate the background:rgba(226, 93, 141, 0.76) attribute into the body:after psuedo-element once my page has finished loading. Below is my HTML and CSS code: <style runat="server" id="myStyle" > body:after{ position:fix ...

Location appearing feature activated by clicking on navigation buttons

I've been having trouble getting the navigation locations to appear and disappear. I'm not very familiar with JavaScript, but I suspect that's the issue. My goal is to make the locations (WebDesign, Photography, SketchUp, Photoshop, About, H ...

Tips on showcasing footer image with full width on any screen dimensions

I need assistance with making my footer background image responsive. Currently, the image is displaying correctly on small screens, but on larger screens it is only centered with empty space on both sides, which is not ideal. Below is the CSS code I have ...

The button text in Bootstrap 5 is black instead of white as shown in their demo

During the installation of Bootstrap 5, I encountered an issue where many of my buttons are displaying a black font instead of the expected white font as shown in the Bootstrap 5 Documentation For instance, the .btn-primary button on the official Bootstra ...

Handle all link clicks on the webpage

My challenge is that some users are required to utilize a virtual desktop in order to access specific information on my website. However, within the virtual environment, there are links leading to external content that do not function properly. I am seekin ...

Revamping Tab Styles with CSS

Currently, I am working on a mat tab project. The code snippet I am using is: <mat-tab-group> <mat-tab [label]="tab" *ngFor="let tab of lotsOfTabs">Content</mat-tab> </mat-tab-group> If you want to see the liv ...

Electron does not prioritize the @css prefers-color-scheme option

I recently completed an Electron project and decided to incorporate dark mode support into it. However, for some reason, the dark mode feature is not functioning properly. Below you will find the dark.css styling that I have included in every page: @medi ...

Struggling with aligning form-group elements along with razor html helper buttons in Bootstrap's form-horizontal layout

I'm struggling with properly aligning buttons in my razor markup. When using form-horizontal: <div class="row"> <div class="col-md-6"> <div class="form-group"> @html.labelfor @html.editorfor @html.validation ...

Incorporating CSS into an HTML page created by a Python CGI script

Last week, I was handed a Python-based monitoring and notification tool to work on. My task is to develop a proof of concept dashboard using the data collected by this tool over the years. The catch is that I'm fairly new to Python and have never dabb ...

Displaying the structure of a MongoDB database using Express and Angular in a tabular format

I am looking to present the data from MongoDB in a table format using HTML along with Node.js, Express.js, and Angular.js. Currently, my approach is as follows: route.js app.get('/superhero', function(req, res) { superhero.superhero_list(r ...

Utilizing CSS to style the disabled selection in the absence of an optgroup

I am encountering an issue with a select component that has grouped options and a default option. The CSS styling is not being applied to the option without a group. I would like to change the color of the hidden disabled option to match the placeholder. ...

Enhancing transparency with a touch of background color

After successfully exporting my chart created in canvas as an image file, I noticed that the image turned out to be transparent without any background. Is there a way through code to add a background color to this existing image obtained from canvas? For ...

The issue arises from the fact that the Bootstrap modal fails to open automatically

Having trouble getting my bootstrap modal to open on page load, even though the button to trigger it is working fine. Here is my code: <div id="myModal" class="modal fade" role="dialog"> <div class=" ...

Utilize Vue.JS to showcase JSON information from an external file

Currently, I have a View.JS app that displays a conversation thread from a JSON file. The existing code appears as follows: const app = new Vue({ el: "#app", data: { messages:[ { name: "Support", message: "Hey! Welcome to suppo ...

Is a page reload triggered by clicking a webelement?

My Latest Project Lately, I've been working on developing a utility method to enhance my Selenium automation testing. This method aims to locate and wait for web elements efficiently, supporting various locators and incorporating timeouts for better ...