The items in the footer are not all aligned on a single line

Trying to create a footer with two linked images, I used justify-content: center, but it seems to be centering the images from the start rather than their actual centers. This causes them to appear slightly off to the left. Additionally, the images are stacking on top of each other instead of being in line as I intended.

.footer-contents {
    /* display: inline-block; */
    text-align: center;
}

.footer-logo {
    position: relative;
    /* align-items: center;
    justify-content: center; */
    /* margin: 0 clamp(10px, 3vw, 30px); */
    /* top: 80px; */
    /* flex-basis: auto; */
    height: 40px;
    width: auto;
}

.column {
    float: left;
    width: 33.33%;
    margin: 5px;
    /* padding: 5px; */
    vertical-align: middle;
}

.row {
    margin: 0 40%;
}
  
.row::after {
    content: "";
    clear: both;
    display: table;
}
<footer class="footer">
        <div class="footer-container bg-container">
            <div class="footer-content">
                <div class="row">
                    <div class="column">
                        <a href="https://twitter.com/">
                            <img src="https://img.icons8.com/color/48/000000/twitter--v1.png" alt="" class="footer-logo">
                        </a>
                    </div>
                    <div class="column">
                        <a href="https://instagram.com/">
                           <img src="https://img.icons8.com/color/48/000000/instagram-new--v1.png" alt="" class="footer-logo">
                        </a>
                    </div>
                  </div>
            </div>
        </div>
</footer>

Answer №1

First and foremost, there appears to be a typo error in your code. Your HTML references a class called "footer-content," while the CSS mentions a class named "footer-contents." This discrepancy could be causing your issue.

Alternatively, if you simply want to center two images, you can achieve this with less HTML and CSS. Here's a simplified version:

<footer class="footer">
    <div class="footer-container bg-container">
        <div class="footer-content">
            <a href="https://twitter.com/">
                <img src="./images/twitter-logo.png" alt="" class="footer-logo">
            </a>
            <a href="https://instagram.com/">
                <img src="./images/instagram-logo.png" alt="" class="footer-logo">
            </a>
        </div>
    </div>
</footer>

I have removed the row and column attributes (assuming they are not needed elsewhere) and utilized the text-align property instead:

.footer-content {
    text-align: center;
}

.footer-logo {
    height: 40px;
    width: auto;
}

If your images are on separate rows due to using a div element with display:block, consider using a span or directly placing the images without enclosing them in a div, as demonstrated above.

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

Loading elements of a webpage in a consecutive order

I am currently working on implementing a content slider within my Django application. The specific slider that I am using can be found at this link. One challenge that I am facing is the need to load close to one hundred 'contentDiv' pages, and I ...

Using JQuery to automatically set the default selection when toggling the visibility of a div

I currently have a script that toggles the visibility of a div when selected: $('.showSingle').click(function () { $('.targetDiv').hide(); $('.showSingle').removeClass('greenactive'); $(this).addCla ...

Error message: Uncaught SyntaxError: Unexpected import token encountered in (ReactJS, Babel, Webpack, NodeJS)

I've been struggling for days to get this simple Hello World app working using ReactJS and Babel. I have installed node.js and webpack, but unfortunately, I keep encountering the following error: Uncaught SyntaxError: Unexpected token import Below ...

Events related to key press timing in HTML 5 canvas

Currently, I am developing a game similar to Stick Hero for Android using HTML5. I am working on the code that will capture the time of key press (specifically the right arrow key with ASCII 39) in JavaScript and expand a stick accordingly. <!doctype h ...

Creating a dynamic and unique border design in MUI

Currently, I am working with React 17 and MUI version 5.6. My component requires the ability to dynamically add new borders to the parent container based on user input. While I have come across CSS tutorials that demonstrate how to achieve this effect usin ...

Design an HTML watermark input that remains visible as the user starts typing

I'm currently in the process of developing an application that enables businesses to access their account through theirname.mydomain.com. I am working on creating a signup form for this purpose. Today, I stumbled upon squarespace and noticed they hav ...

The console is displaying the array, but it is not being rendered in HTML format in AngularJS

Can you please review my App.js file and let me know if there are any mistakes? I have provided the necessary files index.html and founditemtemplate.html below. Although it is returning an array of objects in the console, it is not displaying them as inten ...

Unusual Blank Space in HTML CSS Design

While working on my website, I noticed a peculiar white space appearing at the bottom of the page, but only when using Internet Explorer. Safari looks fine. I am currently using IE8. I would like the white background to end after the black navigation link ...

I attempted to implement a CSS and Typescript animation for a sliding effect, but unfortunately, it isn't functioning

So I'm encountering an issue with this unique ts code: {/* Mobile Menu */} <div className="lg:hidden"> <button className="flex items-center w-8" onClick={toggleMenu}> {isMobileMenuOpen ? ( ...

Maintaining uniformity in Python by assigning and populating empty values for any missing HTML tags to ensure consistency across structures

Here are the HTML lines I currently have: <nonDerivativeTable> <nonDerivativeHolding> # First Holding <securityTitle> <value>Common Stock</value> </securityTitle> <ownershipNat ...

Pass information submitted through a JavaScript prompt to an expressjs endpoint

I'm currently facing a challenge in extracting the value from my prompt in order to modify a category using a JavaScript function. Typically, I would rely on a form to pass variables to the request.body, but that's not an option here. This is wh ...

Explore the world of HTML by uncovering both the tags and

I am currently focused on enhancing a table I created to allow sorting rows in both ascending and descending order, as well as the ability to rearrange columns through click-and-drag functionality. While the basic structure is working, I am seeking to refi ...

Nested div elements maintain background-image continuity

Is it possible to maintain the background image of the body within a child div that has a red background color with opacity? * { box-sizing: border-box; } body { background-image: url('https://d6scj24zvfbbo.cloudfront.net/306f4bc782c04bbe4939f8c ...

What is the best way to filter specific data types when using ngFor in Angular?

As I loop through the array named "fruits," which contains objects of type "FruitService" that I created, I want to display each element. However, when I delete them (I know it's strange, no database involved), they turn into type "undefined" and star ...

Express-minify is having trouble loading the CSS file. If we remove a portion of the file, it should be able

After implementing the express-minify middleware, I encountered an issue with loading the attached CSS file. Even after validating the CSS using an online service, no errors were detected. I attempted to debug by gradually removing elements, and the prob ...

Is the mobile site displaying CSS pixels in the physical pixel resolution?

I am struggling to grasp the problem and finding it challenging to explain it clearly, so I have attached a picture depicting the issue. https://i.stack.imgur.com/E9Gzj.png My current approach involves using ratios of 100% and 100vw for element widths. D ...

Load the page's content gradually, without needing to wait for all the content to be fully loaded

I am facing an issue with a webpage that displays 10 different items, each of which has a slow loading time. Currently, the entire page waits for all 10 items to fully load before displaying anything. I am interested in finding out if it is feasible to sh ...

Retrieve a result following an AJAX post request to utilize the obtained value in subsequent code functionalities

Below is the code snippet where an "if" statement is used to check if a query has been executed correctly. If it has, a part of the script is stored in a variable called $output. This variable is then immediately read by the notification script included in ...

Input field that adjusts its width based on screen size, accompanied by two buttons displayed side

I need a solution to display a text input and two buttons side by side. The buttons should take up only the space they require, while the text input should expand to fill the remaining space. It's important to have small margins between these elements ...

exploring the seamless transfer of values between Thymeleaf and Spring controllers, and vice versa

As a newcomer to thymeleaf, I'm seeking guidance on how values are passed between the thymeleaf HTML and Spring controllers. Could someone please recommend some helpful tutorials for thymeleaf-spring-mvc? In the following example, I would like to und ...