The height of the logo is not the same as the height of the menu

Seeking assistance with aligning a logo next to the navigation menu on my website. Despite my attempts to adjust margins and paddings, the logo and menu appear to be misaligned. As a beginner in CSS, any guidance or tips would be highly appreciated!

https://i.sstatic.net/bRdBQ.png

.btn-header a{
    color:#999;
    background:rgba(0, 0, 0, 0.5);
    padding:10px 20px;
    font-size:12px;
    text-decoration:none;
    letter-spacing:2px;
    text-transform:uppercase;
}

.btn-header .icon {
    display: none;
}

.btn-header a:hover{
    border:none;
    background:rgba(0, 0, 0, 0.4);
    background:#fff;
    padding:20px 20px; #000;
    color:#1b1b1b;
}

.btn-header  img{
    display: inline-block;
}
.footer{
    font-size:8px;
    color:#fff;
    clear:both;
    display:block;
    letter-spacing:5px;
    border:1px solid #fff;
    padding:5px;
    text-decoration:none;
    width:210px;
    margin:auto;
    margin-top:400px;
}
<div id="header" class="btn-header">
        <img src="http://via.placeholder.com/50x50" height="50" width="50"/>
        <a href="#" >How it works</a>
        <a href="#" >Blog</a>
        <a href="#" >Store</a>
        <a href="#" >Join Us</a>
        <a href="#" >Repair</a><a href="javascript:void(0);" class="icon" onclick="myFunction()">&#9776;</a>
    </div>

Answer №1

Simply include img {vertical-align:middle} in your CSS and the image should align properly...

If you wish to specify the width and height of the image, be sure to include those values in the img rule

.btn-header a{
    color:#999;
    background:rgba(0, 0, 0, 0.5);
    padding:10px 20px;
    font-size:12px;
    text-decoration:none;
    letter-spacing:2px;
    text-transform:uppercase;
}
img {vertical-align:middle; width: 150px; height; 150px}

.btn-header .icon {
    display: none;
}

.btn-header a:hover{
    border:none;
    background:rgba(0, 0, 0, 0.4);
    background:#fff;
    padding:20px 20px; #000;
    color:#1b1b1b;
}

.btn-header  img{
    display: inline-block;
}
.footer{
    font-size:8px;
    color:#fff;
    clear:both;
    display:block;
    letter-spacing:5px;
    border:1px solid #fff;
    padding:5px;
    text-decoration:none;
    width:210px;
    margin:auto;
    margin-top:400px;
}
<div id="header" class="btn-header">
        <img src="http://via.placeholder.com/50x50" height="50" width="50"/>
        <a href="#" >How it Works</a>
        <a href="#" >Blog</a>
        <a href="#" >Shop</a>
        <a href="#" >Join Us</a>
        <a href="#" >Repair</a><a href="javascript:void(0);" class="icon" onclick="myFunction()">&#9776;</a>
    </div>

Answer №2

Utilize tabelas para o pai (.btn-header) e células de tabela e alinhe verticalmente: meio para o filho (.btn-header img, .btn-header a)

.btn-header a{
    color:#999;
    background:rgba(0, 0, 0, 0.5);
    padding:10px 20px;
    font-size:12px;
    text-decoration:none;
    letter-spacing:2px;
    text-transform:uppercase;
}

.btn-header .icon {
    display: none;
}

.btn-header a:hover{
    border:none;
    background:rgba(0, 0, 0, 0.4);
    background:#fff;
    padding:20px 20px; #000;
    color:#1b1b1b;
}
.btn-header { display: table;}
.btn-header  img{
    display: table-cell;
    vertical-align: middle;
}
.btn-header a {display: table-cell;
vertical-align: middle;}
.footer{
    font-size:8px;
    color:#fff;
    clear:both;
    display:block;
    letter-spacing:5px;
    border:1px solid #fff;
    padding:5px;
    text-decoration:none;
    width:210px;
    margin:auto;
    margin-top:400px;
}
 <div id="header" class="btn-header">
        <img src="http://via.placeholder.com/50x50" height="50" width="50"/>
        <a href="#" >Como funciona</a>
        <a href="#" >Blog</a>
        <a href="#" >Tienda</a>
        <a href="#" >Trabaja con nosotros</a>
        <a href="#" >Reparar</a><a href="javascript:void(0);" class="icon" onclick="myFunction()">&#9776;</a>
    </div>

Answer №3

Include the following CSS

#header{
justify-content: center;
align-items: center;
}

Check out the Fiddle

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

Is there a way to effortlessly scroll an element when the CSS overflow property is designated as auto?

I need help with creating a testimonial section where two divs automatically scroll inside a fixed-height container. Currently, only one div is scrolling while the other remains static in my code. I have implemented JavaScript for automatic scrolling wit ...

Styles for the Top-bar Navigation in Foundation Framework

Is there a way to customize the default styles of the top bar and nav bar in my project? I have already referred to the Foundation Docs regarding the Top Bar, which mentions the use of SASS. However, I am unsure about how to implement it. Any guidance wou ...

Achieving the extraction of a particular string from an HTML element using JavaScript

<input id="WD01B3" ct="CB" lsdata="{2:'WD01B4',4:'Any',20:'\x7b\x22WDA_TYPE\x22\x3a\x22DROPDOWN_BY_KEY\x22,\x22WDA_ID\x22\x3a\x22ABCA950297D2C0C432BAB9BB ...

Issue with retrieving the current location while the map is being dragged

How can I retrieve the current latitude and longitude coordinates when the map is dragged? I've tried using the following code: google.maps.event.addListener(map, 'drag', function(event) { addMarker(event.latLng.lat(), event.la ...

The animation for the Bootstrap modal is not functioning correctly

Whenever I click the button to open the modal window, it just pops up without any animation or fade effect. I attempted to add classes like .fade and .modal-fade to the modal, but nothing changed. You can see it in action on my test page. Simply click th ...

Reacting to a situation where the tailwind grid has an issue: the responsive column span is visible in the HTML, but

I'm having an issue with a grid that is not behaving as expected. I have set up a jsfiddle to show the behavior I am looking for, which relies on the responsive code: col-span-3 md:col-span-2 for one of the items. The problem arises when I inspect th ...

I am looking to switch the content between two divs. Specifically, I want to take the content from div 1 and move it to div 2, while moving the

I am facing a challenge involving three divs. One of them is the main div, while the other two are positioned below it and contain different content. I am trying to find a way to swap the content between div one and div two in such a way that the original ...

Getting the present location on Google Maps for the web: A step-by-step guide

As a newcomer to this API, I have successfully generated an API key but am unsure of how to implement Google Maps. Despite my extensive research, I have been unable to find a solution that works for me. I am seeking assistance in locating users or devices ...

Challenges faced with Vuetify's vertical and non-linear stepper components

I've been struggling to grasp the concept of Vuetify's stepper feature. Despite my efforts, I haven't been successful in combining different steppers from their page that each have elements I need but lack others. One example is this one on ...

Tips for automatically incorporating animation upon page initialization

I'm looking to add an automatic image effect when the page is loaded. I currently have this code in my js file: $(window).ready(function(){ $(pin).click(function(){ $("#pin01").show().animate({left: '650px'}); }) }); Here is the HTML wit ...

Is there a reason why the slide up feature is not working when I include the ul tag?

I need help with a jQuery code that will pull up/slide up an Html "p" tag when my page finishes loading. This snippet of jQuery code seems to be working fine: $(function () { $('.graybgc').slideUp(0); }); This is the HTML structure: <p ...

Looking for assistance with implementing mouseover scrolling on an unordered list

I am attempting to create a scrolling effect on my UL element when the mouse hovers over it, but I am having trouble getting it to work. Here is the link to my fiddle: http://jsfiddle.net/MisterStorm/4ja9apqz/3/ and here is my code: $(document).ready( ...

Angular silhouette casting on CSS fold

I am attempting to recreate this design as accurately as possible, but I am struggling with replicating the shadow effect on the right side. Is it achievable using CSS? CSS: *{margin:0px;padding:0px;} html { width:100%; height:100%; te ...

Endlessly tapping through each tab with no direction

I am attempting to click on all unopened tabs (elements) randomly across this page. While the code below usually does the trick, it sometimes doesn't click on all elements. I suspect that there might be an issue with how it loads indexes or some othe ...

How to effectively implement light and dark themes using SCSS colors?

Currently, I am utilizing Vue.js and SCSS along with PrimeVue and Element plus, where I am importing their variables. My objective is to dynamically change the theme color. In my dark-variables.scss file, I have defined various color variables for differe ...

Utilizing distinct JavaScript, JQuery, or CSS for individual Controllers within the Codeigniter framework

Currently, I am involved in a Codeigniter v3 project where we are developing a comprehensive application for a large organization. To optimize the loading speed of each page, I am looking to integrate custom JQuery and CSS files/code specific to each Con ...

My observations on CSS challenges in IE7/8 and the Hashchange plugin

What is causing these float issues in Internet Explorer? Additionally, has anyone had any experience with 'jquery.ba-hashchange.min.js' and know how to make the hashchange function more visually appealing? Thank you! ...

What is the best way to combine multiple classes when declaring them in CSS?

I'm attempting to combine the following code snippets (possibly misunderstood the term) - is there a way to have them both perform the same function without creating another class with identical attributes? .games span { display: inline-block; ...

Steps for creating a transparent Bootstrap navbar:1. Start by creating

I have Bootstrap HTML code for a navbar <!--Navbar--> <nav class="navbar navbar-expand-lg navbar-dark bg-dark"> <img class="logo" alt="Brand" src="images/1.png"> <a class="navbar-brand" href="Homepage.jsp">Car ...

Increase the padding on Bootstrap 4 Sticky footer for a more polished look

While working on my Bootstrap 4 website hosted on Apache (Ubuntu Linux), I encountered an issue with the sticky footer. When there is only a small amount of content on the page, I have to scroll through excessive white space to reach the footer. I'm ...