Reorganizing elements within a navigation bar using CSS

Check out the screenshots to see what I am aiming for here.

https://i.sstatic.net/fFBQh.jpg

https://i.sstatic.net/DAEJM.jpg

I am trying to align the menu list items (My application, Register, Login) to the far right of the screen. Despite experimenting with margins and float:right, I haven't been able to achieve this yet.

The container div takes up the full width. Do you think I need to make changes to this div?

I've put together a codeped to demonstrate this

https://codepen.io/jquerypain121/pen/OJNaWpa

<html><head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Log in - PhotoUploaderForm</title>

</head>
<body>
    <header>
        <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-dark bg-white border-bottom box-shadow mb-3">
            <div class="container">
                <img src="https://lh3.googleusercontent.com/proxy/HQAE10KQ0NmS9htB5BKSoN24jWvyaizAKwhGy8hNVVsCbFUubvDdLSsYB8xWbN3JUDzDuAzw0OxKO5QZyL_XPqitq1wcSYaMVJ35_oC48c4FKZYykJUoucS-LJT1" width="200" title="title" alt="additional title">

                    <a class="navbar-brand" href="/">My Application</a>

                <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">

                    <ul class=" moveright nav navbar-nav">
                            <a class="navbar-brand" href="/">My Application</a>
                            <li class="nav-item">
                                <a class="nav-link text-dark" id="register" href="/Identity/Account/Register">Register</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link text-dark" id="login" href="/Identity/Account/Login">Login</a>
                            </li>
                    </ul>

                    <ul class="navbar-nav flex-grow-1">
                    </ul>
                </div>
            </div>
        </nav>
    </header>

    <div class="container-fluid">
        


        <main role="main" class="pb-3">
            


<h1>Log in</h1>
<div class="row">
    <div class="col-md-4">
        <section>
            <form id="account" method="post" action="/Identity/Account/Login" novalidate="novalidate">    
                <hr>
                <div class="text-danger validation-summary-valid" data-valmsg-summary="true"><ul><li style="display:none"></li>
</ul></div>
                <div class="form-group">
                    <label for="Input_Email">Email</label>
                    <input class="form-control" type="email" data-val="true" data-val-email="The Email field is not a valid e-mail address." data-val-required="The Email field is required." id="Input_Email" name="Input.Email" value="">
                    <span class="text-danger field-validation-valid" data-valmsg-for="Input.Email" data-valmsg-replace="true"></span>
                </div>
                <div class="form-group">
                    <label for="Input_Password">Password</label>
                    <input class="form-control" type="password" data-val="true" data-val-required="The Password field is required." id="Input_Password" name="Input.Password">
                    <span class="text-danger field-validation-valid" data-valmsg-for="Input.Password" data-valmsg-replace="true"></span>
                </div>
                <div class="form-group">
                    <div class="checkbox">
                        <label for="Input_RememberMe">
                            <input type="checkbox" data-val="true" data-val-required="The Remember me? field is required." id="Input_RememberMe" name="Input.RememberMe" value="true">
                            Remember me?
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-primary" formaction="/Identity/Account/Login?returnUrl=%2F">Log in</button>
                    <input type="hidden" id="ReturnUrl" name="ReturnUrl" value="/">
                </div>
                <div class="form-group">
                    
                    <p>
                        <a href="/Identity/Account/Register?returnUrl=%2F">Register as a new user</a>
                    </p>
                    
                </div>

            <input name="__RequestVerificationToken" type="hidden" value="CfDJ8PEcG7qoomVJk-wiZaqy0p6b5tfvXZTuVH-9YakoOKQQf8mWfBn4MYD7BCb3YKL_NmEz_Ru57zD8PV8Tq_6ea5WApccwrpwYrOkBdu7Qu9Z6NMycGCHqDTI35Ci1mPMVQSqyQ47sNdvfhZhfkMSx_DQ"><input name="Input.RememberMe" type="hidden" value="false"></form>

        </section>
    </div>
    <div class="col-md-6 col-md-offset-2">

    </div>
</div>


        </main>
    </div>
    <footer class="border-top footer text-muted">
        <div class="container">
            <p style="float:left;color: white;">© 2020 - Leicestershire Health Informatics Service -</p>
            <a style="float:right; margin-right: 10px;" href="/Home/Privacy">Privacy</a>
            <a style="float:right;margin-right: 10px;" href="/Home/Information">Info</a>
            <a style="float:right;margin-right: 10px;" href="/Home/TermsAndConditions">T&amp;C</a>
        </div>
    </footer>







</body></html>

Your assistance would be greatly appreciated. Thank you

Answer №1

If you want to achieve a specific design using Bootstrap, there's no need to customize the code. Bootstrap provides its own sleek and modern design options that you can easily implement. Check out this link for more information: https://getbootstrap.com/docs/4.5/components/navbar/

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-light bg-light">
  <a class="navbar-brand">
   <img src="https://getbootstrap.com/docs/4.5/assets/brand/bootstrap-solid.svg" width="30" height="30" class="d-inline-block align-top">
  My Application
  </a>
  <div class="form-inline">
    <a class="nav-link text-dark" href="">My Application</a>
    <a class="nav-link text-dark" id="register" href="/Identity/Account/Register">Register</a>
    <a class="nav-link text-dark" id="login" href="/Identity/Account/Login">Login</a>
  </div>
</nav>

Answer №2

To align your list to the right, use the ml-auto class in your ul instead of moveright.

Answer №3

Set the navigation's width to 100% and then float the unordered list to the right;

Fingers crossed that it does the trick

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

I find myself grappling with the styling issue in MUI select

<FormControl> <Select labelId="unique-label" id="unique-id" value={1} className={styles.uniqueCustomSelectRoot} IconComponent={() => <MyUniqueIcon />} sx={{ " ...

Assistance with embedding html characters into a page title

While this issue isn't urgent, knowing the solution would be really beneficial to me. I've been following Ryan Bates' technique for adding titles to pages, and I must say, he's a fantastic pioneer and asset to the Rails community, don&a ...

Frustrated with the endless page loading caused by three.js

I've been trying to incorporate three.js code to showcase a 3D model in GLTF format, but my webpage keeps getting stuck on pre-loading. I need assistance with displaying a preloading page until all the files are fully loaded. Any help in resolving th ...

The first generation iPad, CSS3 transformations, and the constraints on image processing due to limited RAM

During my exploration of the original iPad on iOS 5.0.1, I stumbled upon some peculiar quirks that appear to be linked to the number of images being loaded into the browser simultaneously. I noticed certain things rendering at half resolution or even lowe ...

Submitting values in URI through an HTML form

Hey there, I'm really in need of some assistance with this issue that's been driving me crazy... :) So, I'm working on a project using Symfony2 and AngularJS: <form class="navbar-form navbar-right" role="form" action="" method="post"> ...

Is there a way to format the text into a curved half-capsule shape?

<div class="bg-primary rounded-pill"> <p class="text-right"> TOTAL AMOUNT </p> <p class="text-right"> 200 </p> </div> I would like the text within a div element to appear in a capsule shape. Is there a way t ...

Rotate the circular border in a clockwise direction when clicked

I have successfully designed a heart icon using SVG that can be filled with color upon clicking. Now, I am looking to add an outer circle animation that rotates clockwise around the heart as it is being created. Currently, the circle only spins in the code ...

Tips for updating the color of the mat-paginator's border at the bottom

Is there a way to change the border bottom color of my mat-paginator when an option is selected? It currently defaults to purple, but I would like to customize it. Any suggestions? Click here for an example of the current purple border on Mat-paginator. ...

Click to reveal additional images once the "show more" button is pressed

Hey there! I'm currently working on implementing a feature where, upon clicking "show more", 3 images will be displayed. And if the user clicks again, another set of 3 images will appear, and so on. I seem to be facing some difficulties with the JavaS ...

I'm having trouble getting my button to float correctly on the right side

Here I am facing a unique situation where I am attempting to align my button input[type="submit"] to the right side. I have allocated space for it and therefore trying to float the button to the right so that it can be positioned next to my input text. U ...

Can PurgeCSS be implemented with Next.js and module.scss files?

Is there a way to use purgeCSS with component level .scss files (filename.module.scss) in order to remove unused CSS? The hashed classnames make it tricky, especially in a next.js app that heavily relies on module.scss files for styling. This thread here ...

Transfer data in an array within value="" separated by ':' through AJAX/JSON in PHP and HTML

Can data be passed in array form using AJAX/JSON? For example, like ".$row['departmentname'].":".$row['jobposition'].":".$row['deptcode']."? Here is a sample code snippet to illustrate this: if(sqlsrv_num_rows($query) > 0 ...

Modify a JavaScript class using d3 select and filter operations

I have a function that I've been working on. Initially, I change all classes to "badge badge-secondary". Then, I check the text in the span. If it says "right" and is clicked, I update it to "badge badge-primary". If the text is "wrong" and clicked, ...

Creating a switch statement that evaluates the id of $(this) element as a case

I have a menu bar with blocks inside a div. I am looking to create a jQuery script that changes the class of surrounding blocks in the menu when hovering over a specific one. My idea is to use a switch statement that checks the ID of $(this) and then modif ...

Tips for Expanding the Height of a Parent Div to Fill Its Containing Parent

I am experiencing some difficulty with a seemingly simple task. My goal is to have the lime-colored background expand and fill 100% of the current height of its parent container (in this case, the magenta-colored section). Here is a live example: https:/ ...

In what way has SoundCloud managed to achieve this?

With their UI consisting solely of HTML, CSS, and JS, the question arises: how are they able to play audio without any visible flash player? ...

Positioning a .png file in the center of a div while giving it a high z-index

Is it possible to ensure that a .png image is always centered in a div, regardless of the device size, and appears above another .png image within the same div? Below is the HTML code snippet: <div class="col-sm-6"> <div id="spi ...

Dividing one SVG into Multiple SVGs

I'm facing a challenge with loading an SVG overlay on a Google Map. The SVG file is quite large, about 50mb, resulting in a delay of around 10 seconds for it to load in the browser. One solution I'm considering is splitting the SVG into 171 smal ...

What is the best way to open an already existing tab in Safari using an HTML 'a' link?

Is it possible to return to Safari after launching another app? <a href="webbrowserapp://example.com/open?url=http.....">Open WebBrowserApp</a> I've tried using: <a href="safari://">Return to Safari</a> It would be ideal if ...

Issues with both horizontal and vertical bootstrap navigation bars functionality

My attempt to incorporate both a vertical and horizontal Bootstrap menu on my webpage led to the layout being disrupted. Is there a solution for this issue? Below is the code for my horizontal menu: <html lang="en"><head> <meta charset ...