The Ul Li tag cannot be aligned to the right

Having trouble left aligning the logo and right aligning the ul li tag? Despite using float, the code doesn't seem to work as expected. Take a look at the issue:

It's puzzling because I've used the same code elsewhere and it worked perfectly. But this time around, for some unknown reason, it's not getting right aligned.

@charset "utf-8";
/* CSS Document */


html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}



/*
font-family: 'Source Sans Pro', sans-serif;
font-family: 'Archivo Narrow', sans-serif;
font-family: 'Comfortaa', cursive;
*/


body {
font-family: 'Archivo Narrow', sans-serif;
}

.head {
width: 100%;
margin: 0 auto; 
padding: 0px;
background-color: #855fa8; 
}

.menu {
width: 1020px;
margin: 0 auto; 
padding: 0px;
overflow: hidden; 
padding-top: 20px;
}

.left-menu {
width: 15%;
float: left;
}

.left-menu img {
display: block;
width: 100%;
}



.right-menu {
width: 70%; 
float: right; 
}







/*Strip the ul of padding and list styling*/
ul {
list-style-type:none;
margin:0;
padding:0;
position: absolute;
}

/*Create a horizontal list with spacing*/
li {
display:inline-block;
float: left;
margin-right: 1px;
}

/*Style for menu links*/
li a {
display:block;
min-width:80px;
height: 50px;
text-align: center;
line-height: 50px;
font-family: 'Archivo Narrow', sans-serif;
color: #fff;
text-decoration: none;
}

/*Hover state for top level links*/
li:hover a {
background: #19c589;
}

/*Style for dropdown links*/
li:hover ul a {
background: #f3f3f3;
color: #2f3036;
height: 40px;
line-height: 40px;
}

/*Hover state for dropdown links*/
li:hover ul a:hover {
background: #19c589;
color: #fff;
}

/*Hide dropdown links until they are needed*/
li ul {
display: none;
}

/*Make dropdown links vertical*/
li ul li {
display: block;
float: none;
}

/*Prevent text wrapping*/
li ul li a {
width: auto;
min-width: 100px;
padding: 0 20px;
}

/*Display the dropdown on hover*/
ul li a:hover + .hidden, .hidden:hover {
display: block;
}

/*Style 'show menu' label button and hide it by default*/
.show-menu {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
text-decoration: none;
color: #fff;
background: #19c589;
text-align: center;
padding: 10px 0;
display: none;
}

/*Hide checkbox*/
input[type=checkbox]{
    display: none;
}

/*Show menu when invisible checkbox is checked*/
input[type=checkbox]:checked ~ #menu{
    display: block;
}


/*Responsive Styles*/

@media screen and (max-width : 760px){
/*Make dropdown links appear inline*/
ul {
position: static;
display: none;
}
/*Create vertical spacing*/
li {
margin-bottom: 1px;
}
/*Make all menu links full width*/
ul li, li a {
width: 100%;
}
/*Display 'show menu' link*/
.show-menu {
display:block;
}
}
<div class="head">

<div class="menu">
            
                   <div class="left-menu">                   
                        <img src="http://i.imgur.com/MvTUZ36.png" alt="logo">
                    </div><!-- left menu --> 
                    
                    <div class="right-menu">
                        
                                   <label for="show-menu" class="show-menu">Show Menu</label>
                                    <input type="checkbox" id="show-menu" role="button">
                                <ul id="menu">
                                <li><a href="#">Home</a></li>
                                <li>
                                    <a href="#">About ↓</a>
                                    <ul class="hidden">
                                        <li><a href="#">Who We Are</a></li>
                                        <li><a href="#">What We Do</a></li>
                                    </ul>
                                </li>
                                <li>
                                    <a href="#">Portfolio ↓</a>
                                    <ul class="hidden">
                                        <li><a href="#">Photography</a></li>
                                        <li><a href="#">Web Design</a></li>
                                        <li><a href="#">Illustration</a></li>
                                    </ul>
                                </li>
                                <li><a href="#">News</a></li>
                                <li><a href="#">Contact</a></li>
                            </ul>
                            
                    </div><!-- right menu --> 
        </div><!-- Menu --> 

    </div><!-- head --> 

Answer №1

To properly align your ul#menu, you need to eliminate the position:absolute and instead utilize float:right.

Simply include the following in your CSS:

ul#menu {
    position: static;
    float:right;
}

Answer №2

Seems to function correctly when I remove the position:absolute from your list (UL) and eliminate the fixed percentage width from the right-hand menu.

Answer №3

Eliminate the CSS rule for width: 1020px in the element with class .menu

Update the CSS property of .left-menu img from width:100% to width:130px

Include the CSS rule body {overflow:hidden;}

Replace width: 70%; with width: 430px in the styling of the element with class .right-menu

Answer №4

Employ the Twitter Bootstrap framework for your project. For more information, visit this link.

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 the method for altering the "return" of a CSS transition?

Today, I delved into the world of transitions and I must say, they are amazing and have great potential for future websites. Take a look at my current code: http://jsfiddle.net/Ldyyyf6n/ I am looking to tweak the "return" transition of the circle/square ...

Expanding the Background Color when Hovered Over

Despite my extensive search on SO, none of the answers I found seem to address my specific situation. In a col-md-2 section where I have a navigation bar, I am trying to change the background color to extend up to the border when hovering. While I can cha ...

Is there a way to add the date icon next to the date picker input in Bootstrap 5?

I'm struggling with getting the date icon to display after the date selection input in Bootstrap 5. It keeps showing up below it instead. https://i.sstatic.net/kD2GL.png Here is the code I am using: <form data-toggle="validator" class=& ...

How can I align a button right next to the table row data in HTML using Bootstrap?

Is there a way to add a button next to the table data in each row without a border? I attempted to create a new column for the button, but the border interferes with the design. I am using Bootstrap 4 for this project. Here is the HTML code: <div cl ...

Execution of Javascript code does not provide the expected output when run via VS Code

I've attempted numerous times, but the desired output doesn't appear when I run it through VS Code. However, this code runs smoothly and produces the desired output when executed in Replit's online code editor. Can anyone offer assistance? l ...

What is the solution to the error message stating that <tr> cannot be a child of <div>?

displayTodos() { return this.state.todos.map(function(item, index){ return <div todo={item} key = {index}>; <tr> <td>{item.todo_description}</td> <td>{item.todo_responsible}</td> ...

Error: Unexpected end of argument list in file c:/.../list.ejs during ejs compilation

Hello, I am a beginner in programming and I have been working hard to learn. Unfortunately, I encountered a SyntaxError: missing) after argument list in c://.../list.ejs while compiling ejs error and I am struggling to find the solution. I am reaching out ...

Implementing nested CSS styles with jQuery - a step-by-step guide!

In my stylesheet.css file, I have the following code: .vertical-navigation .navbar-default .navbar-nav > li > a:hover { background-image: url(../images/sticcky_nav_hover.png) } .vertical-navigation .navbar-default .navbar-nav > li > a.navf ...

Clicking on a link initiates the dropdown menu for selecting an option

This project is specifically designed for mobile use, so there's no need to worry about how it will appear on desktop screens. In this project, I have an "a href" with an icon next to it that simulates a button. When a user clicks on it, a dropdown me ...

Is storing HTML tags in a database considered beneficial or disadvantageous?

At times, I find myself needing to modify specific data or a portion of it that originates from the database. For instance: If there is a description (stored in the DB) like the following: HTML 4 has undergone adjustments, expansions, and enhancements b ...

The usage of CSS pseudo elements with the position absolute property

To allow for the opacity of an image to be changed without affecting the parent container's opacity, I added the image as a pseudo-element. The position of the pseudo-element is set to absolute and relative to the parent to position it inside the p ...

Modifying the position of an image in Flask

I am trying to center an image on my webpage and have attempted the following code: <image height="300px" width="300px" src="{{url_for('static',filename = 'img/Rasd.jpeg')}}" > Visit this webpage fo ...

Exploring the mechanics of aligning a div using Bootstrap 4

I recently found a code snippet that beautifully centers a login box, which I implemented. However, I realized that I actually wanted the login box to be positioned 25% from the left instead of 50%. The interesting part is, the code doesn't follow the ...

Generating a vertical line right in the middle of the list item

I have recently designed an HTML page featuring a list of links using ul and li elements, with a customized background color for each li. Now, I am looking to add vertical lines next to the li items. When attempting to insert an image, my output looks lik ...

What could be the reason behind encountering an NaN error while using these particular functions?

I recently delved into the world of JavaScript, starting my learning journey about two months ago. While going through a few tutorials, I stumbled upon an intriguing project idea. However, I've hit a roadblock that's impeding my progress. Every t ...

What is the best way to ensure that the viewBox of an SVG perfectly matches the size of the image it overlays?

I am looking to create a simple GUI using the Python NiceGUI Library. In my design, I have divided the interface into two columns using the grid element, with cards containing checkboxes on the left for overlays. On the right side, I have inserted an imag ...

"Responsive header design using Bootstrap for both desktop and mobile devices

Is there a way to create a header that adjusts its width based on the device viewing it, with maximum width for desktop and no padding for mobile? Here is an example of the code: <div class="row"> <div class="span12"> ...

Unexpected behavior in grid column layout in Bootstrap 4 has caused some confusion

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> <div class="row"> <div clas ...

Utilizing Bootstrap4 Grid System: Flex for SM and beyond, Row then Column for XS viewports

I'm in the process of developing a menu system specifically tailored for XL, LG, MD, SM screens in BOOTSTRAP4 while offering a unique appearance for XS (mobile) devices. Here is the HTML code I currently have: <div class="container-fluid"> ...

JavaScript error leading to ERR_ABORTED message showing up in the console

When I try to load my HTML page, my JavaScript code keeps throwing an error in the console. I am attempting to import some JavaScript code into VSCode using an app module for future reuse. The code is being run through a local server. Error Message: GET ...