CSS styling for positioning a dropdown submenu

My website is experiencing issues with the CSS sub menus, specifically the last two sub menus are extending off the screen.

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

I am looking for a solution to maintain the correct position of these sub menus. The code contains some minor CSS tweaks and is quite lengthy, so I will not be posting it in its entirety here. You can view the live site with the problem at www.brandstik.in

Answer №1

To effectively manage the positioning of your last 2 or 3 menu links and their sub-menus, you can use the following CSS code:

Custom CSS:

.main-menu > li:nth-last-child(1) ul.submenu,
.main-menu > li:nth-last-child(2) ul.submenu,
.main-menu > li:nth-last-child(3) ul.submenu {
    right: 0;
}

By implementing this code, you will be able to adjust the positions of the sub-menus for the last 3 children links in your menu.

Answer №2

attempt

ul.super-child:last-child, ul.super-child:nth-last-child(2) {
   right: 0px;
}

The second container will now be positioned perfectly within the view.

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

Loading a div class dynamically with JQuery

It's clear to me there is an issue with my code, and I'm reaching out for assistance. Here is the problematic snippet that needs fixing. Currently, I'm encountering this error message: Uncaught TypeError: Cannot read property 'find&apos ...

How can one access a div tag within a script using Jquery?

I am faced with a challenge related to accessing the div tag "warningMessage" within my HTML code. Below is the snippet that contains this div tag under scripts: <script id="notePopup" type="text/x-kendo-template"> <p class="notePopupMessage" ...

One div takes a backseat to the other div

I recently delved into learning Bootstrap, but I'm baffled as to why one div is appearing behind another. <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Fa ...

Can you explain the meaning of -ms-value?

I recently came across a solution for an issue specific to IE, and it worked perfectly for me. You can find the solution here: Change IE background color on unopened, focused select box However, I'm still puzzled about the meaning of -ms-value. Any i ...

The Clash Between Jquery 2.1.1 and Lightbox

I am trying to incorporate a photo upload feature with a lightbox on a single page, however, I encountered a conflict between my jquery-2.1.1 and lightbox js. I attempted to use jQuery.conflict(); to resolve the issue, but it resulted in another error "jQu ...

Using Javascript to Change the Radio Station Station

I am a beginner in the world of programming and I am attempting to make this feature work. My goal is to give the user the ability to select the radio station they want to listen to. Here is what I have come up with, but unfortunately it is not functioni ...

Gray lines on page not moving

I am experiencing difficulty in getting my HTML page to scroll properly. Despite trying various CSS properties for Overflow (such as scroll, auto, visible, etc.), I have been unsuccessful in making the page scrollable. It seems like there might be a simpl ...

CSS animation stalling

While my angular app is loading all the necessary content through ajax, I display a loader on top of the content on a darker layer. The SVG used in this process contains an animateTransform: <svg width="38" height="38" viewBox="0 0 38 38" xmlns="http: ...

How can I add a % symbol to user input in a text input field?

When utilizing a number spinner, I'm looking to include the % symbol in the input box by default. I attempted using a span, however, it places the symbol outside the box. ...

javascript - Retrieving a JSON string

I am currently working on a stock website where I need to retrieve JSON information from either Google's API or Yahoo's API. To test this functionality, I have used a replacement function to log the data onto a text box for testing purposes. Howe ...

Adhesive Bottom Navigation, Top Banner, and Full-Height Page Content

Trying to create a header, sticky footer, and content section with 100% height, but facing issues with the middle height. Below is the code and jsfiddles provided. Using HTML 4.0 strict in IE7 without the option to change. jsfiddle without 100% height: ht ...

Create a speech bubble using only CSS, featuring a partially see-through background and a stylish border

I wish to design a speech bubble using only CSS. There are specific requirements I need to meet: It should adjust its size based on content with some padding or a set size. The background color must be semi-transparent. You must be able to define a borde ...

Obtain the final card within a column of cards using Bootstrap 4

I am currently using Bootstrap 4 to create a masonry card deck that consists of 3 columns with 3 cards each. I am wondering if there is a way to target the last card in each column individually. I know how to target the very last card across all columns: ...

A distinct vertical line separating two buttons

I'm currently working on an Angular 2 app using Angular material. I have two buttons labeled "sign in" and "sign up", and I'm trying to add a vertical line between them. Despite looking at various examples online, I haven't been successful i ...

Incorporate descriptive text to my HTML slider

How do I customize my carousel to display unique titles or captions for each slide? Here is the code snippet provided: <h1>Incredibly Basic Slider</h1> <div id="slider"> <a href="#" class="control_next">>></a> < ...

JavaScript can dynamically attach EventListeners to elements, allowing for versatile and customized event

I am currently populating a table using data from an XML file. One of the columns in the table contains links to more details. Due to the unique requirements of my web page setup (Chrome extension), I need to dynamically add an event handler when the table ...

Execute code after the CSS has been loaded, but before the images start downloading

My website is experiencing a challenge. Downloading images is taking too long, with the complete website taking around 20 seconds to fully load on my system. A loader is displayed but only hides once the complete website is loaded (after 20 seconds). Whe ...

Uncommon problem with generating links

I am facing an issue with creating a link in the header bar of a website that was developed by another company. Despite having some HTML experience, I'm struggling to resolve this problem. The link I created for a page named gallery.php within the sam ...

Error Message: Angular Typescript: x function is not defined

UPDATE: Huge shoutout to everyone who caught my mistake with the code location... Haha I've been wrestling with this issue all day long - the button should trigger the menu to open and switch to "close menu" after displaying a list of 3 items. The co ...

When using HTML5's checkValidity method, it may return a valid result even if

Consider the following scenario: <input pattern="[a-z]"/> If you run the command below without entering any input: document.querySelector('input').checkValidity() You will notice that it actually returns true. This seems counterintuiti ...