List that is aligned to the right side

I have been searching for videos on coding, bootstrap, and CSS. I have tried everything but I still can't figure out which attribute to set for the drop-down list so that when it expands, the list item margin will align to the right of the parent item. Currently, it is aligned to the left by default. I want the drop-down list to look like this upon expansion: [1]: https://i.sstatic.net/Fu3AY.png][1]

Without adjusting the margin, my drop-down lists end up looking like this: all elements are aligned to the left of the parent menu. However, if I adjust the margin, the list loses responsiveness when the view size changes. [2]: https://i.sstatic.net/ks5q5.png[2]

Has anyone encountered the same issue and do you have any suggestions on how to resolve it? Here is a snippet of my list code:

<div class="menu">
    <button>Menu</button>
    <ul>
        <li><a href="#">MoonLight Ltd Co.</a></li>
        <li><a href="#">Introduction</a></li>
        <li><a href="#">Services</a></li>
        <li><a href="#">Contacts</a></li>
    </ul>
</div>

Answer №1

Below are the custom codes I implemented for the ul & li:

              .navbar-wrapper .right-side-wrapper ul {
                margin:0px;
                padding:0px;
                position: absolute;
                list-style: none;
                border-radius:3px;
                text-align: end;
                opacity: 0.5;
                pointer-events: none;
                transform: translateY(10px);
                transition: all 0.5s ease-in;
                background:rgba(255, 0, 0, 0.6);
                font-size: calc(8px + 0.5vw);

              }
              .navbar-wrapper .right-side-wrapper li {
                position:relative;
                width:calc(100px + 3vw);
                padding:1vh;
              }

Answer №2

There are multiple options you can consider for aligning your list items to the right.

ul {
    text-align: right;
}

or

ul {
    text-align-last: right;
}

or

li {
    float: right;
}

li {
    text-align: right;
}

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

Using App Storage on Windows Phone 8 with HTML5

Exploring storage options for my html5 app compatible with both windows 8 and windows phone 8. Considering: Local Storage IndexDB Looking for advice on the best storage mechanism to use. Is IndexDB compatible with windows phone 8? Any insights on quota ...

Learn the process of extracting HTML content from a webserver response and displaying a specific tag value in a combobox within a desktop application using VB.NET

I am currently attempting to retrieve data from a URL using HttpWebRequest/HttpWebResponse in VB.NET desktop application. The response I receive is displaying the entire HTML content in a message box. Now, my objective is to extract a specific tag (TD tag) ...

AngularJS encountered an error: The token '|' was unexpected and expected ':' instead

My HTML file contains a condition where certain fields need to be displayed automatically in landscape mode using filters. However, when I run the program, I encounter the following code: <tbody> <tr ng-repeat="ledger in vm.ledgers ...

Angular Update Component on Input ChangeEnsuring that the component is automatically

<div class=" card-body"> <div class="row"> <div class=" font-icon-list col-lg-2 col-md-3 col-sm-4 col-xs-6 col-xs-6" routerLinkActive="active" *ngFor="let subject of subjects"> <div class=" fon ...

From Button to Picture Button

Having an issue with my dropdown menu. After selecting a location, clicking on the "go" button should direct me to another page. Here is the HTML code for the button: <input type="button" name="button" class="gobutton" onclick="openDir(this.form);"> ...

Using HTML and C# to Deliver Emails

I've encountered a challenge with my HTML page that includes a textbox for users to input their email. When the submit button is clicked, an email should be sent to a specific email address defined in the code, and a pop-up box indicating "Email Sent" ...

Jquery double-click Event Not Functioning Properly

I've been attempting to toggle the visibility of my footer navbar while also changing the chevron icon. When the navbar is hidden, I want the chevron pointing up to be displayed, and when the navbar is shown, I want the chevron pointing down to be dis ...

What is the best way to determine if a radio button has been chosen, and proceed to the next radio button to display varied information?

The goal is to display the <div class="resp"> below each radio button when it is selected, with different content in each <div class="resp">. The previously selected <div class="resp"> should be hidden when a new radio button is chosen. O ...

bespoke filter designed to conceal any negative figures

I am trying to implement a feature where a text box will display nothing if the ng-model contains a negative value. I want the ng-model to remain unchanged while ensuring that negative values are not displayed. I am looking for a custom filter to achieve t ...

Header that sticks to the top of a container as you scroll through it

Many questions arise regarding sticky elements in the DOM and the various libraries available to handle them, such as jquery.pin, sticky-kit, and more. However, the issue with most of these libraries is that they only function when the entire body is scro ...

Endless time continuum within the scheduling application

Looking for a way to make the time axis in my scheduling app infinite? Currently, it has a fixed length, but I want users to be able to scroll endlessly into the past or future. Any suggestions on how to achieve this? Check out this JSBin for a basic exam ...

Circular Segment Button in Ionic 2

Is there a way to change the appearance of a segment button from square to round using CSS? https://i.sstatic.net/KRjSh.png I attempted to use traditional CSS, but encountered issues when Ionic2 attempted to transform the button on segment-activated. You ...

Implementing a delay of X seconds after a click event in JQuery: A step-by-step guide

Is there a way to delay the triggering of a click event after one has been recently triggered? I am facing an issue on my website where users can click multiple times on the "dropdown icon" and cause it to toggle the slide effect multiple times. What I wan ...

In order to achieve a sliding effect for the second div, it can be programmed to

Currently, I am working on implementing hide and show functionality in my project. However, I have come across a bug in my code that I need assistance with. When clicking on the first div element, the content opens from bottom to top instead of the desired ...

Is it possible to trigger an update in a Django view with an HTML input even when there is no form update required?

How can we trigger a template refresh using an HTML form from the form itself when it seems no updates are being displayed? Here is a scenario I encountered: A view that generates a random number:- def test_random_view(request): varid=randint(1,1000) ...

Utilizing jQuery to retrieve data attributes from an HTML Select element, and incorporating an SQL query to dynamically populate additional HTML input fields within Classic ASP

From the title, you can probably gather a bit about the issue I'm facing. I have limited experience with classic ASP, but it's still used at my workplace. They've asked me to make some edits that involve adding validation for input fields. S ...

What is the best way to manipulate the size and orientation of an image upon hovering over

I'm struggling to figure out how to simultaneously rotate and scale a .png file when the user hovers over it. Currently, it only scales when I hover on the picture. I understand that the scale property overwrites the first transform but I can't s ...

Show different text or letter when hovering

Is there a way to hide one letter and display another in a link, with a different style on hover? For example: This is a... ...regular link. And this is a... ...hovered link. Any ideas on how to make this happen? Thank you. Edit: Just to clarify — ...

Ways to create a transparent parallax background

Currently, I'm tasked with developing an educational website using HTML and CSS for a school project. Unfortunately, due to restrictions on code.org, I cannot utilize JavaScript files or script tags. Despite successfully implementing a parallax effect ...

Ensure that the heights of various Flexbox rows are always visible within the boundaries of the browser window

Within flexbox, I've laid out three rows of boxes with varying heights. This layout ensures that the rows always align perfectly with the bottom of the browser window without any gaps. You can see the full layout on Codepen by following this link: htt ...