Elements in PureCSS dropdown menu extend beyond the page boundaries

Is there a way to prevent the right menu dropdown child elements from extending off the page? I believe it requires some simple CSS adjustments, but I'm not sure which styles to modify. Any guidance would be greatly appreciated.


    <!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Your custom page title here</title>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pure/0.6.0/pure-min.css">
    <style>
        ul{background-color: #4CAF50; width: 100%}

    </style>
</head>

<body>
<div class="pure-menu pure-menu-horizontal">
... (omitted for brevity)
        </li>


    </ul>
</div>
</body>
</html>

I am aiming to align them on the right side of the page without exceeding the boundaries.

Thank you!

Answer №1

To achieve the desired result, some adjustments in your CSS will be necessary. I have cleaned up your code and provided a JSFiddle for reference.

Simply add the class .right-menu to the rightmost menu for everything to work as intended.

.pure-menu-horizontal .right-menu .pure-menu-children {
  left: auto; /* Adjust position from right */
  right: 0; /* Adjust position from right */
}

Update:

I incorporated display: flex; to resolve an issue with Firefox displaying the desired menu correctly.

Add the following CSS rules:

.pure-menu-horizontal .pure-menu-list.pure-menu-list {
  display: flex;
}

.pure-menu-horizontal .right-menu {
  margin-left: auto;
}

Take a look at my updated JSFiddle for more information on utilizing the convenient flexbox property. Further details can be found on the Mozilla Developer Network.

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 for adjusting the focus effect of mat-icon-button

I am encountering an issue with a button on my page. Here is the code for the button: <button mat-icon-button color="black" style="height: 21px; bottom: 8px;" *ngIf="!transaction.HasMatch" (click)="matchPayable($event, ...

Tips for utilizing .html?q= as a hyperlink shortening method

I've been thinking, is there a way to create a simple JavaScript shortening tool where I can manually input the code for JavaScript? Like this: function shortenUrl() { window.location.href = "http://link.com"; } In this code snippet, 12345 repre ...

Text is being truncated in the title instead of moving to the next line

<View style={{ flexDirection: 'row', alignItems: 'center', height: 130, marginVertical: 10, overflow: 'hidden' }} > <Image sour ...

JavaScript file input/output that is not dependent on any specific web browser

I have exhaustively searched both here and elsewhere online for a solution to my problem, however, I have been unsuccessful. Despite encountering numerous code snippets in javascript and jquery that claim to create and write to a txt or html file, none of ...

Navigating up and down effortlessly using bootstrap

My webpage has a collapsible form located near the bottom, but when it's opened users must scroll down to see all of it. Is there a way to automatically scroll down when it's opened and then scroll back up when closed? Take a look at my code: & ...

"Discover the simplicity of customizing Bootstrap 5 with an easy-to-use online tool

When I was using Bootstrap 3, there was a convenient tool that allowed me to customize which features I wanted in the minified CSS/JS files to improve loading time. Now, as I delve into the documentation for Bootstrap 5, I find myself struggling to unders ...

Using jQuery to dynamically swap out <tr> tags and all the elements inside of them

In order to enhance user experience, I am looking to automatically fill in certain form elements within a table when a link is clicked. The intention is for the fields to populate with predefined values and then convert into HTML paragraph elements, preven ...

What is preventing me from using JavaScript to remove this class?

Struggling to implement a skeleton loading screen with CSS classes and JavaScript. The idea is to apply the 'skeleton' class to elements, style them accordingly, then remove the class using a timeout set in JavaScript. However, I'm encounter ...

JavaScript code for Tree not functioning correctly on Internet Explorer

Seeking assistance to fix a bug in my JavaScript program. The code works perfectly on Google Chrome and Firefox, however it encounters an error in Internet Explorer 8 as indicated below. Any suggestions on how to resolve this issue would be greatly appreci ...

Tips for ensuring smooth rendering of big fonts in Chrome on OSX

On my Macbook Pro running Mojave, I noticed that regular fonts appear normal, but large fonts look jagged in Chrome (unlike Safari or Firefox). You can see an example on CodePen .large { font-size: 300px; font-weight: bold; } Chrome https://i.sstat ...

What is the best way to remove query string parameters prior to running a function when a button is clicked?

I'm facing an issue trying to implement a button that filters events based on their tags. The problem arises when the tag value in the query string parameter does not clear when other buttons are clicked. Instead, the new filter tag value adds up with ...

Passing dynamically loaded parameters to a function during dropdown value selection in Angular 2

Could you please review if I am passing the parameters correctly in the li tag's click function of the updateId method? The console errors only point to that line. This is my app.component.html code: <div class='form-group' style="width ...

How can I enlarge the arrow of the React Tooltip component?

I've extensively reviewed the official documentation, but I couldn't find a way to adjust the size of the arrow in the React tooltip. <span className="icon margin-10-right txtSize20 txtBlue icon_profile-menu icon-tool" data-tip={`&l ...

How can I make my navbar visible once a specific section has been reached?

Is there a way to conditionally display my navbar in react only when a specific section is reached? Currently, I am monitoring scroll position but this method becomes unreliable on larger screens due to varying scroll positions. I need the navbar to beco ...

What's causing the discrepancy in my output result?

Here is the HTML markup: <!DOCTYPE html> <html> <head> <title>My Website</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="t ...

The Regex.Replace function is not functioning as expected

I am currently faced with the challenge of replacing HTML tags within a string. For example, I need to convert <strong>text</strong> to <b>text</b>, among other similar replacements (although I understand that the b tag is considere ...

Exploring ways to style font families for individual options within ng-options

I am looking to display a combobox where each option has a different font. While using the ng-options directive in AngularJS to populate the options for a <select> tag, I am struggling to set the font-family for individual options. $scope.reportFon ...

Guide to integrating the Duda White Label API with an HTML website

Currently, I am in the process of integrating the Duda White Label API into a .html page to ensure that it aligns with my custom CSS. To guide me through this task, I am referring to the instructions provided at: After inserting my API key, Password, and ...

Storing data in HTML5 localStorage using XML or JSON format

A sample of an XML file is provided below: <itemnumbers> <item> <itemno>123</itemno> <desc>Desc about 123</desc> </item> <item> <itemno>456</itemno> <desc/> </item> ... </itemnu ...

Incorporating HTML coding into SharePoint Online

Can HTML codes be added to SharePoint Online? I am interested in adding an HTML code from Statista, like the one below: <a href="https://www.statista.com/statistics/262861/uk-brent-crude-oil-monthly-price-development/" rel="nofollow"><img src=" ...