Place the div at the center within the header

I'm struggling to center the logo in my media query for screens below 479px. Whenever I use margin auto, the image gets pushed to the right by the browser. Here is what I have so far and any assistance would be greatly appreciated.

HTML

<div class="wrapper">
    <header>
        <div id="logo">
            <img src="images/Bliss_FinalLogo_2.png" alt="Logo" />
        </div>
    </header>

CSS

@media only screen and (max-width: 479px){

    li.main_nav {
        float:none;
        width:100%;
    }

    .learn_info {
        width:100%;
    }

    nav {
        margin: 0 auto;
        background: none;
        border:none;
    }

    #logo{
        display: block;
        margin-left:auto;
        margin-right:auto;
    }

    a{
        -webkit-border-radius: 5px;
        -moz-border-radius: 5px;
        border-radius: 5px
    }

}

Answer №1

To ensure proper alignment, it is recommended to define a width for the #logo element. Alternatively, you can apply the style text-align:center to the header section if specifying a width is not desired.

http://example.com/code-demo

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

The AJAX success function is operational, yet the file does not execute

As a newcomer to StackOverflow and web development, I am pressed for time with this assignment, so please bear with me if I struggle with understanding web development terminologies. My current challenge involves calling another php file through ajax in my ...

Adjusting the Size of an HTML Slideshow

While designing a homepage for my band, I encountered an issue when trying to integrate a slideshow element from an external source. The size of the slideshow is fixed at 600 x 300px and cannot be adjusted. Additionally, I found it challenging to position ...

Bootstrap cards have a fixed width and do not wrap

I've been diving into Django and although I'm fairly new to CSS, I managed to put together a page displaying various products using Bootstrap cards. https://i.sstatic.net/xme5m.png It appears that my code should have wrapped these cards pr ...

Positioning Firefox absolutely within a table-cell element is possible

Interestingly, it's not Internet Explorer causing me trouble this time, but Firefox. Here is the Fiddle link for reference: http://jsfiddle.net/EwUnt/ The purpose of this table is to highlight both the row and column of the cell where the cursor is ...

CSS selectors target all elements within a specific div container

Is there a way to select all checkbox input elements that are not contained within a div class that begins with 'xyz_' using CSS? If so, how can this be achieved with a CSS selector? ...

Show the first letter of the first name using HTML

Is there a way to display the first letter of the first name followed by a period, a space, and then show the last name in asp/html/vb? ...

No adjustment in color upon switching themes

I've been struggling to achieve the desired outcome while working on a small coding task. The goal is to modify the color of the screen background, text, and button as illustrated in the uploaded image. I have three code files for this task - index, t ...

showing divs in a compact layout on smaller screens using Bootstrap 5

Is there a way to set up two div elements so that they are displayed as blocks on small screens and inline on large screens? I also need their width to span 100% of the screen. ...

Overlay a div on top of an image in an HTML email

To display text over an image in HTML email, I am looking for a solution since using margin or position is not working as required. Below is the code snippet I have tried: <div style="padding-right:25px;padding-left:20px"> <div style="padding-t ...

Step-by-step guide on achieving a radiant glow effect using React Native

I am looking to add a glowing animation effect to both my button and image elements in React Native. Is there a specific animation technique or library that can help achieve this effect? While I have this CSS style for the glow effect, I am uncertain if ...

The modal box should adjust its height to perfectly accommodate the content within

I'm in the process of developing a straightforward modal (popup) window, using as few lines of code as possible... just the basics. The modal has a maximum width of 650px and its height adjusts to fit the content. In case the content exceeds the avai ...

What is the best way to remove a border piece with CSS?

Currently, I'm attempting to achieve a matrix effect purely through HTML and CSS. One method I have come across involves applying a solid border and then removing certain parts at the top and bottom. Does anyone know if it's possible to create th ...

Warning issued after numerous clicks

My goal is to implement an Alert System that notifies the user when they leave a field empty. Currently, if a field is left empty and the next button is clicked, an alert pops up. However, if the same field is left empty again and the button is pressed, mu ...

Angular Navigation Bar with Tab Elements

I'm looking for recommendations on how to create a tabbed navbar in Angular without redirecting to other pages. I want the user to be able to click on a tab and have a specific component displayed without losing any data, as it will be used for an ext ...

The Microsoft Booking feature is not being shown in the iframe

https://i.sstatic.net/QYNGI.png Instead of the booking website, this is what is being displayed. Below is the code snippet: index.js import React from 'react' const Appointment = () => { return ( <iframe src='https://outlook ...

How can the issue of the background fill option covering multiple loading bars be resolved?

I am currently relying on Google Translator, so there may be errors in the translation. The issue I am facing is that when I add a parameter with the "fillColor: '#f4f5f9'", the wheel covers one of the elements of Multiple Bars. I have modified ...

Looking to update a component in Vue 3 and Laravel 9 without the need to reload the entire webpage

Looking for a solution to refresh the header component upon clicking the logout button, in order to display the login and register options without refreshing the entire page. Any effective suggestions on how to achieve this are greatly appreciated. The l ...

What steps can I take to avoid MathJax equations overlapping with dropdown menus in Bootstrap version 5.2?

Currently, I am in the process of developing a website utilizing Bootstrap 5.2 which features MathJax equations and dropdown menus integrated into the navbar. However, there is an issue where the MathJax equations are overlapping with the dropdown menus, c ...

What is the proper way to retrieve this stylesheet and add it to the header of my HTML file?

I want to utilize a style sheet from Wikipedia. However, when I fetch the style sheet and attempt to pass the URL retrieved through AJAX to the head of my HTML document, the URL behaves unexpectedly. Initially, I tried to use the fetched URL directly: var ...

Looking to incorporate Slick Carousel as the main slider on my website for a dynamic hero section using JavaScript

Currently in the process of expanding my knowledge in javascript, I am now delving into setting up Slick Carousel. It is essential that it functions as a hero slider on my website. If you are interested in checking out Slick Carousel on github, feel free ...