What is the best way to vertically align and float images to the edges?

Is there a way to align images inside a nav tag and position them at the edges of the navigation element?

I've been researching and attempting to use vertical-align: middle and float, but they don't seem to have any effect on how the elements are displayed.

Check out the code on Codepen: https://codepen.io/centem/pen/BaajLZm

#company-name {
  float: left;
  vertical-align: middle;
}

.logo {
  float: right;
  vertical-align: middle;
}

img {
  height: 40px;
  vertical-align: middle;
}

Answer №1

There is no need for vertical-align here because the "nav" element already has "display: flex;" applied to it. Simply add the property "align-items: center;" to the CSS of the "nav" element.

nav {
font-family: monospace;
width: 100%;
margin: auto;
display: flex;
align-items: center;
justify-content: center;
background: rgb(67, 66, 66);}

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

Highlighting the selected value in an Angular Material mat option

I am looking to enhance the background color of the selected value when it is clicked. Unlike the example I found, which highlights multiple select values, I only want to highlight the selected value when choosing an option. Check out this example for ref ...

Handling click events for parent and child elements in Angular 5

In Angular5, Below is the code I am working with: <div (click)="abc()"> some content <button (click)="xyz()">Click</button> </div> When I click on the button, both methods are being called. I want only a sin ...

Display or conceal a division depending on the content contained within it

I am attempting to conceal the image containers on these pages depending on whether there is an image uploaded for a specific event or if the container contains a placeholder image. The only distinction between the two images is the path to the image and t ...

The popup generated by the window.open() function appears blank and does not display any content

I have a Django website with this url that contains the following code in its footer template: <img referrerpolicy='origin' id='rgvjjxlzwlaoesgtfukzjxlz' style='cursor:pointer' onclick='window.open("https://logo.sam ...

Tips for CSS: Preventing onhover animation from resetting with each hover

I've created an on-hover CSS animation that smoothly transitions between images. However, I encountered a lagging issue when the user quickly hovers over SECTION ONE and SECTION TWO before the animation ends, causing the animation to restart and lag. ...

Creating uniform heights for HTML column-based tables using divs in a React environment

I am developing a unique column-oriented and div-based table using React with Typescript. The data outside the table is organized in a column-based structure, rendering column 1 followed by row 1, row 2, row 3, then column 2 with its respective rows. The ...

Switching the orientation of an iPhone on Chrome can lead to content being cut off

Currently, I am conducting testing on an iPhone XS running iOS 15.6.1 The website seems to function properly on iOS Safari (although untested on Android), however, a problem arises when using Chrome and rotating the screen from landscape to portrait mode. ...

Create a CSS menu that spans 100% of the width

I am struggling with making a responsive menu 100% width of the page. I have applied the CSS code below to the "rmm" class, but it is still not achieving the desired full width effect. How can I make the menu stretch 100% across the width of the page? .r ...

Tips for getting rid of the excess space surrounding an image within a div tag

Placing images inside bootstrap card divs within col divs is my current challenge <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" /> <div class="container"> <div class="row"& ...

I currently have some code for a toggle button and a collapse feature, but I'm struggling to integrate the two

I need assistance with implementing a toggle animation I found here: https://codepen.io/7harrypotterrr/pen/OrBwPY. I'm unsure how to apply it to my code and replace the current toggle button that is in use here: https://codepen.io/7harrypotterrr/pen/e ...

Steps to resolve transition zoom issues with images

I'm having trouble showcasing blog posts with an image. Currently, I am utilizing card-columns from Bootstrap 4, and when the user hovers over the image, it scales up. The issue arises when the transition occurs, as my border radius resets to defaul ...

What are some methods for converting data from data tables into alternative formats?

I need assistance exporting data from data tables in various formats such as Copy, CSV, Excel, PDF, and Print. Can someone show me how to do this for the example provided below? <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.4 ...

Guide on updating a table with query parameters in Html Agility Pack using C#

Struggling with parsing this URL using the Html Agility Pack: " The default table that shows up is always based on the closest contract date and the current date. I can parse the entire page without any issues, but when I try to request a different date ...

Conceal the ::before pseudo-element when the active item is hovered over

Here is the code snippet I am working with: <nav> <ul> <li><a href="javascript:void(0)" class="menuitem active">see all projects</a></li> <li><a href="javascript:void(0)" class="menuitem"> ...

Steps to minimize the Bootstrap expanded menu on devices such as iPhone, iPad, Smartphones, tablets, etc. by simply tapping outside of the menu

Hello there! I'm currently working on a website project using Bootstrap framework v2.0.1. One interesting challenge I'm facing is related to the navigation menu behavior on different devices such as iPhones, iPads, tablets, and smartphones. When ...

Finding the Closest Element with jQuery's .closest() Method

I'm facing an issue while trying to select an element that is positioned above another element. Specifically, I want to target the nearest occurrence of the .discount-dropdown class that appears above the .discount-type class. Can anyone help me figur ...

Can an HTML select box have a horizontal scroll bar added to it?

I am facing an issue with the following HTML code. <!DOCTYPE html> <html> <body> <select> <option value="volvo">Volvoooooooooooooooootooooooolargeeeeeeeeeeee</option> <option value="saab">Saab& ...

What could be causing my React Router component to display incorrect styling?

While working with react-router, I encountered an issue where the text from the routed page started appearing in the navbar. Even though I separated it as its own component and it functions correctly, this specific problem persists. As a newcomer to React, ...

Employing jQuery to eliminate background image from a specific list

Looking for a way to eliminate the background image from a specific list within an unordered list tagged with the dfwp-list class? Unfortunately, my current code isn't doing the trick. $("ul.dfwp-list > li").css('background-image':' ...

The functionality of data attributes in jquery mobile is not functioning correctly

Within my header, I have included the following code: <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.5.css"> <script type="text/javascript" src="js/jquery-1.11.2.js"></script> <script type="text/javascript" src="js ...