Link aligned to the right

Recently, I added some menu links in the blue area on . However, I am now looking to add a right aligned link while keeping the others left aligned. My attempt using [method] didn't work. Any suggestions on how I can achieve this?

Answer №1

Instructions: Add a child div for the links on the right side. Check out this example.

Here is the HTML code:

div id="ovoMenu">
    <a href="?i=1">Item 1</a>
    <a href="?i=2">Item 2</a>
    <a href="?i=3">Item 3</a>
    <div class="right">
        <a href="?i=4">Item 4</a>
    </div>
</div>

CSS styling:

.right {
    text-align: right;
    float: right;
}

#ovoMenu {
    margin: 0px;
    padding: 0px;
    /* Size properties */
    padding-top: 5px;
    /* Font properties */
    color: #FFFFFF;
    font-size: 80%;
    /* Create a gradient background */
    background-color: #418CE5;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#418CE5', endColorstr='#256EC6');
    background: -webkit-gradient(linear, left top, left bottom, from(#418CE5), to(#256EC6));
    background: -moz-linear-gradient(top, #418CE5, #256EC6);
    /* Prevent links from wrapping to a new line */
    white-space: nowrap;
}

#ovoMenu a:link, #ovoMenu a:visited, #ovoMenu a:active, #ovoMenu a:hover {
    color: #FFFFFF;
    /* Rounded corners */
    -moz-border-radius-topleft: 4px;
    border-top-left-radius: 4px;
    -moz-border-radius-topright: 4px;
    border-top-right-radius: 4px;
    /* Adjust size and spacing */
    margin-left: 12px;
    padding-left: 12px;
    padding-right: 12px;
    /* Display as block elements */
    display: inline-block;
    /* Set height of the link */
    height: 30px;
    line-height: 30px;
    /* Remove underline */
    text-decoration: none;
    /* Remove outline */
    outline: 0;
}

#ovoMenu a:hover {
    /* Change background color on hover */
    background-color: #13529E;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#13529E', endColorstr='#084084');
    background: -webkit-gradient(linear, left top, left bottom, from(#13529E), to(#084084));
    background: -moz-linear-gradient(top, #13529E, #084084);
}

#ovoMenu a.active:link, #ovoMenu a.active:visited, #ovoMenu a.active:active, #ovoMenu a.active:hover {
    color: #333333;
    font-weight: bold;
    background: none;
    background-color: #E9E9E9;
}

Answer №2

#ovoMenu, #ovoSubmenu { text-align: right; }

Is this what you are looking for?

If you want to align the third item to the right:

<a href="?i=3" style="float: right;">Item 3</a>

Answer №4

To achieve the desired outcome, apply a fixed height to ovoSubmenu and set anchors to float:right. Does this meet your requirements?

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

What is a straightforward method to showcase prototype nodes in PHP?

It's like a different flavor of UI, function DisplayUI($elements) { } This function will display the specified elements with name, id, and type in a flexible manner. UPDATE Create an array and get HTML as output. Has anyone experimented with thi ...

Creating smooth transitions with CSS in React by fading text in when a user clicks a button

Within this presentational component: const HowToControls = props => { return ( <div className="col-md-6 how-to"> {props.isOpen ? <p className={`text ${props.isOpen ? 'visible' : ''}`}> lorem ...

Tips for Minimizing DIV Space with the Flex Property

I need some help with reducing the space between the individual content (1, 2, 3, 4) and its border in this Fiddle. As a newcomer to Flexbox, I'm unsure if there's an easy solution to this issue. Here is a visual representation of what I mean: ...

Issue: Node.js Express unable to access static files when the route is nested more than one folder level deep.Resolution

Before we delve into the question, let me share with you the folder structure of my node.js express app: /home server.js index.html /app /routes public.js /public /css main.css In my server.js file, ...

The output is visible in the Firefox console but does not display on the actual browser

Can anyone help me with a bug in my javascript/jQuery/PHP/mySQL application? When I submit a form, the response is visible in the Firebug console window but not in the browser window. I know this is a vague question, but I'm hoping it might be a commo ...

Increase in textbox size depending on selected dropdown value

Our concept involves offering three choices: Email #1 pulled from the database Email #2 retrieved from the database Input a new email Should the user select option #3, a textbox will expand at the bottom of the dropdown menu for easy entry of a new emai ...

What is the best way to target all div elements containing a child with the class "test-class"?

How can you choose all div elements that contain a child element with the class "test-class"? This question has been identified as a duplicate of Is there a CSS parent selector?. After reading that question, it is evident that this question is indeed redu ...

The elusive Holy Grail layout for Flex content cannot be achieved on IE11

UPDATE I attempted to insert height:100vh into the .app-container, but unfortunately, it did not have the desired effect. I am utilizing bootstrap 4 for creating my web application. My goal is to implement the Holy grail layout. Everything appears to be ...

Wave your way to unique text creation with Firefox

Hey there, I've got some text inside a div that's been transformed with rotate(3deg). Strangely enough, in Firefox, the text appears wavy. When I remove the transform property from the div, the waviness disappears. Is there any way for me to keep ...

Divergent display of WordPress form input CSS between Firefox and Chrome

Trying to create an email opt-in box using Wordpress with a pre-installed theme. The box appears correctly in Firefox but is displaying incorrectly in Chrome. Issues include no padding in the text fields, different font colors, and extra padding above and ...

Can you explain what is meant by an "out of DOM" element?

I'm feeling a bit lost when it comes to DOM nodes and all the terminology surrounding them. Initially, I believed that the DOM consisted solely of what I could see in my inspector - nothing more, nothing less. However, I've come across functions ...

Hovering into Transition Time

My article card has a transition on the top attribute of the info div, which is supposed to be smooth and last for 0.3 seconds. However, the description suddenly appears during this transition. I'm trying to figure out why this is happening and how to ...

Unexpected behavior from HTML5 number input field

Is there a way to prevent users from entering values outside the specified max and min attributes? The constraints work when using the arrows in the input field, but not when typing directly into it. Note: I am considering utilizing angularjs for this fun ...

choose a selection hopscotch

Is there a way to prevent the input field from jumping out of alignment when an option is selected in these q-select inputs? I want to fix this issue so that the field remains in line with the horizontal alignment. https://codepen.io/kiggs1881/pen/RwENYEX ...

Central logo navigation with paired links on each side

I am currently working on creating a navigation bar that features a centered logo with two links positioned on each side. My goal is to have the side links placed closer to the logo than the edges of the page. Initially, I attempted to achieve this using v ...

Arrange divs in vertical columns

My markup is fixed and I am only allowed to add <div> elements to the container. Here is the current structure: <div class="container"> <div class="box" id="box1">1</div> <div class="box" id="box2">2</div> < ...

What is the process for storing a list group in an SQL database?

Having a code snippet in html which populates a list with data selected from a combo box upon clicking the 'add' button. However, running into an issue where "undefined index: subjectlist" error occurs when submitting the form. Seeking advice on ...

Change the appearance of a specific div within a collection of div elements using React

I'm currently working on a visualizer for sorting algorithms where there are colorful bars that will animate when a specific sorting algorithm is triggered by clicking the play button. To achieve this, I created an array of div elements representing ...

Changing the text value and color of a cell in a Jquery Datatable

My datatable uses ajax sourced data, and I have a function that validates cell data and changes the cell color to red if validation fails. There is also a column with initial empty data that gets updated later. I set the rowId as ip_address to identify row ...

What is the best way to prevent the content within a div from being obscured by a sticky element affixed to the bottom of the div?

I am struggling with ensuring that the content in my wrapper does not get cut off by the "view more" div attached to the bottom. The default wrapper cuts off the children, and even when expanded, the issue persists due to CSS problems. In React, the gener ...