The alignment of the image in the Bootstrap dropdown menu is disrupted

Hello! Currently, I am utilizing this bootstrap template from . However, I am encountering an issue with the dropdown menu alignment when I try to add an image to it. Is there anyone who can provide some assistance with this problem?

The complete code was too extensive to include here, so I have uploaded it to this FIDDLE https://jsfiddle.net/Lgdohawm/. Please select Columns Bottom results in the js fiddle editor layout as it will display the full width result page.

Here is a snippet of the menu code (HTML only):

    <header id="header" style="background-color:black">
                 <nav id="nav-menu-container">
                    <ul class="nav-menu">
                      <li class="menu-active"><a href="#intro">Home</a></li>
                      <li><a href="#about">About Us</a></li>
                      <li><a href="#services">Services</a></li>
                      <li><a href="#portfolio">Portfolio</a></li>
          <!-- menu with image -->
                      <li class="menu-has-children"><a href="" class="sf-with-ul"><img class="rounded-circle" width="45" src="https://picsum.photos/50/50">&nbsp;@user</a>
                        <ul>
                          <li><a href="#">Drop Down 1</a></li>
                          <li><a href="#">Drop Down 3</a></li>
                          <li><a href="#">Drop Down 4</a></li>
                          <li><a href="#">Drop Down 5</a></li>
                        </ul>
                      </li>
           <!-- menu with image -->
                      <li><a href="#team">Team</a></li>
          <li><a href="#contact">Contact</a></li>
                    </ul>
                  </nav>
                </div>
              </header>

The menu code can be found between the HTML comments tag <!-- menu with image -->

Answer №1

Is there a specific rationale behind your utilization of

float: left

for the menu items?

You could opt for a simpler approach by using

.nav-menu > li {
    display: inline-block;
}

instead.

Check out this JSFiddle example

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 correct placement of DESC in a MySQL query when using PHP?

Here's the issue I'm facing: $query = "SELECT * FROM table ORDER BY 'timestamp' LIMIT $startAt, $perPage"; I've been attempting to sort the results in descending order (latest on top) by adding DESC to the query. However, every t ...

Using setAttribute will convert the attribute name to lowercase

When creating elements, I use the following code: var l = document.createElement("label");. I then assign attributes with l.setAttribute("formControlName","e");. However, a problem arises where the setAttribute method converts formControlName to lowercase ...

The ::before pseudo element is malfunctioning when used in the makeStyles function

I am currently utilizing the makeStyles function in React, but I seem to be facing an issue where the content within the ::before pseudo-element is not displaying. Strangely enough, when the content is an image it works fine, but text does not render. Jus ...

Transform HTML content into a PDF document

I am dealing with a string that contains HTML data and my goal is to convert it into a PDF using ASP.Net. After searching support pages and using Google extensively, I have not been able to find a straightforward snippet of code for this common task with a ...

Show and hide a div with the click of a button

As I embark on rebuilding a website from the ground up, I find myself pondering how to achieve a specific functionality: My goal is for another view to appear when one of two buttons is clicked. How can this be accomplished? I attempted the following app ...

What is the most efficient method of organizing form components together?

After exploring numerous tutorials, I have yet to discover the ideal solution for properly marking up a form that contains logical groupings of elements such as labels, controls (input or select), and previous values - essentially single fields. My prefer ...

Modifying Label text dynamically using jQuery on Click event

My website HTML contains the following code snippet: <script src="js/jquery.flexslider.js"></script> <script src="js/jquery.rings.js"></script> The contents of jquery.rings.js are as follows: $('input[type="image"]') ...

What could be causing my CSS code to not function properly within Vue.js?

Having trouble with css in VueJs. I can't seem to figure out what I'm doing wrong. Generally, my scoped style css works fine in vuejs, I can target ids and classes without any issues. The problem arises when trying to change the internal css va ...

Triggering a jQuery event upon clicking a link

Trying to achieve a specific functionality here. Clicking on an image triggers a lightbox, but right-clicking and opening in a new tab should lead to a different page. Instagram has a similar feature that I'm aiming for. Using <a href=""> doesn& ...

What is the best way to display two arrays next to each other in an Angular template?

bolded text I am struggling to display two arrays side by side in an angular template. I attempted to use ngFor inside a div and span but the result was not as expected. A=[1,2,3,4] B=[A,B,C,D] Current Outcome using ngFor with div and span : Using Div : ...

Do I have to include the sizes attribute when using w-descriptors in srcset?

After reading several articles discussing the use of srcset for device-pixel-density adjustments and art direction, I have come to a few conclusions: The State of Responsive Images in 2015 by Paddi Macdonnell srcset Part 2: The W descriptor and sizes att ...

Using a CSS height of 100% does not always result in filling 100% of the parent's height

My parent div has a height of 250px. I then have multiple children with their min-height set to 100%. While the debugger confirms that the selector is correct and targeting the right elements, the height does not fill the parent's height at all; inste ...

Utilize JSON data fetched from a URL to dynamically populate an HTML content

There is a JSON file located at a URL that looks like this: [{"tier":"SILVER","leagueName":"Tryndamere's Wizards","queueType":"RANKED_SOLO_5x5","playerOrTeamId":"91248124", "playerOrTeamName":"NunoC99","leaguePoints":18,"wins":411,"losses":430,"rank" ...

Is there a way to automatically display the detailsPanel in Material-table upon loading?

I am currently working on creating a subtable for the main React Material-Table. So far, everything is functioning correctly as expected, with the details panel (subtable) appearing when the toggle icon is pressed. Is there a way to have it displayed by d ...

Selected jQuery plugin is not updating HTML select option

I've been attempting to update the select tag in my HTML file to match the style used in the example on the Chosen v1.8.7 website, but despite following the instructions, the select element remains unchanged: test.html <head> <link rel=& ...

Why use getElementById(id) to obtain an element in JavaScript when it already exists in the JS?

Recently, I have observed that a reference to an HTML element with an id can be easily accessed in JavaScript by using a variable named after that id (jsbin). What is the reason for this behavior? Why do we need to use getElementById(id) when we could sim ...

Steps to apply styles to an iframe element directly from its inner HTML code

Looking for help with this line of code: <iframe src="http://www.google.com" name="google" style="Z-INDEX: 0; MARGIN-TOP: -1px; WIDTH: 100%; HEIGHT: 1070px"> <html> <head></head> <body> < ...

The CSS background image is not functioning

.menubar li { float: left; width: 115px; text-align: center; background-image: url(js/left_main_bg_image.gif); } Having issues with the background image not displaying properly in IE, Firefox, and Chrome. I've tried adding it to a tab ...

Add a specific CSS class to a div element depending on the status of a checkbox

Is there a way to dynamically append data based on the selected items in a checkbox table? I want to be able to add multiple or single items by clicking the add button. The key is to avoid appending duplicate data that already exists in the view. Any sugge ...

Using Django (v3) UserCreationForm, the process of applying Bootstrap4 form-related classes to fields can be simplified

I am currently in the process of creating a registration form. The structure of the form is as follows: class UserSignUpForm(UserCreationForm): username = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control', ' ...