How can I ensure that images remain within the link elements in a flex container?

I'm currently assisting a colleague with his website. His main request is to have the two images positioned below the larger image at the beginning of the page align perfectly with the edge of the page, so that the right image lines up with the one above it.

To address this issue, I developed a small demo. I enclosed the anchors within a flex container and set the flex-basis to 490px. Despite these adjustments, the images are not contained within the anchor elements or the main column container with a width of 1000px. Our goal is to have both images be 490px wide, with the left image aligning on the left edge and the right image aligning on the right edge.

<html lang="en">
<head>
    <meta charset="UTF-8>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    .kickers {
        display: flex;
        flex-wrap: nowrap;
        justify-content: space-between;
    }
    .kickers > a  {
        flex-basis: 490px;        
    }
</style>
<body style="display: flex; flex-direction: column; align-items: center;">
    <div style="width: 1000px; height: 1000px; background-color: red;">
            <div class="kickers">
                    <a href="https://www.machinevisiondirect.com/machine-vision-lights.html">
                        <img src="https://sep.yimg.com/ca/I/yhst-172617910-1_2596_13601540"></a>
                    <a href="https://www.machinevisiondirect.com/swmo.html">
                        <img src="https://sep.yimg.com/ca/I/yhst-172617910-1_2596_13657163"></a></div>
        </div>    
</body>
</html>

Any suggestions on how to achieve this? Thoughts?

Answer №1

Just a small adjustment needed - make sure to include a max-width of 100% on the images to prevent them from overflowing the container.

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    .kickers {
        display: flex;
        flex-wrap: nowrap;
        justify-content: space-between;
    }
    .kickers > a  {
        flex-basis: 490px;    
    }
    .kickers img {
        max-width: 100%;
    }
</style>
<body style="display: flex; flex-direction: column; align-items: center;">
    <div style="width: 1000px; height: 1000px; background-color: red;">
            <div class="kickers">
                    <a href="https://www.machinevisiondirect.com/machine-vision-lights.html">
                        <img src="https://sep.yimg.com/ca/I/yhst-172617910-1_2596_13601540"></a>
                    <a href="https://www.machinevisiondirect.com/swmo.html">
                        <img src="https://sep.yimg.com/ca/I/yhst-172617910-1_2596_13657163"></a></div>
        </div>    
</body>
</html>

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

How can custom CSS and JS be loaded in Sencha Touch based on the user's device - PC, tablet, or smartphone?

Is there a way to configure a webpage so that when the user is accessing it from a PC (using Safari/Chrome/Firefox), they see the "normal" version of the page, but if they are using an iPad to view the same URL, they get Sencha Touch (css, js) files in t ...

Checking the validity of an input element with jQuery: How to determine if the valid or invalid pseudo-class has been applied?

Is there a way to check for the application of the CSS3 :valid or :invalid pseudo-class on an input element using jQuery? I want to verify if the form element has passed CSS validation before allowing the submit button to be enabled. Here are some methods ...

CSS: The calc() function does not take into account the bottom padding when used in Firefox and Internet

I am encountering an issue with the calc() function in Firefox 32 and IE 11, where the bottom padding of a div is not being respected. However, this problem does not occur in Chrome and Opera. The main content section should have a fixed height while allo ...

What are some ways to ensure my web application appears correctly on Internet Explorer versions 8 and 9?

When I compare how my application looks in IE versus Chrome and Firefox, it seems like there are styling issues. I want to address this problem. I attempted to use the IE developer tool but couldn't find any options to customize styles and CSS. How d ...

Can anyone advise on the proper way to import CSS within a React component?

I'm currently working on a React component named Comp1 and I've included a CSS file within it like so: import "./style.css"; Within the style.css file, I'm using the following line: @import "https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi ...

Learn how to showcase real-time stock information from Yahoo Finance on an Android device. See the JSON format provided below for guidance

finance_charts_json_callback( { "meta" : { "uri" :"/instrument/1.0/PTC/chartdata;type=quote;range=1d/json/", "ticker" : "ptc", "Company-Name" : "PTC Inc.", "Exchange-Name" : "NMS", "unit" : "MIN", "timezone" : "EDT", "curr ...

Adjusting the image placement within a modal window (using bootstrap 3)

Behold, an example modal: <!-- Large Modal --> <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"> <div class="modal-dialog modal-lg"> <div class="modal-content"> ...

JavaScript - Fetch POST request is being terminated - Windows Error 10053

Seeking help for my JavaScript project course. The function is aborting during the fetch process. Chrome is the browser being used to test the project. It was intermittently "sending" before, but now it's not working at all. Had to run the app in Chro ...

What is the best method for efficiently loading SVG icons on an HTML page without redundancy? / Is utilizing <use href> recommended?

My struggle with implementing icons in Angular While working on a new Angular project, I've encountered challenges with my current SVG-icon implementation method from a previous project (@ngneat/svg-icon). The process involves organizing SVG files in ...

Tips for showcasing information on an HTML website

I am currently facing an issue with displaying addresses retrieved from a database in my project. The problem lies in the formatting of the address when it is displayed on the page. Currently, the address is being displayed as follows: Address: 1 Kings S ...

Is it possible to incorporate a button and a click event into this JavaScript function?

For over a day, I've been attempting to include three functionalities in this code, but have yet to succeed. 1° My goal is to insert a button on this page. I've attempted to create a standard button using HTML and CSS, but the fireworks displa ...

Unveil/Conceal Div Overlay

Something seems to be off with my current script. When I click on a link in the table, the div overlay is created successfully. However, when I close the div and click on another link, the overlay pops up again and the close button no longer works. I susp ...

What is the method to display Post values to the user without necessitating a page reload?

Currently, I am attempting to utilize Ajax to send the user's inputted data from a JSP page. Through Ajax, I have successfully transmitted the variable "vars" to the Jsp page. The output upon registration includes: Registration is Successful. Welcome ...

Showing a loading animation inside an HTML element

I have a main webpage that contains several buttons. Each button, when clicked, loads a specific target page as an object within a div on the main page. The "target" refers to the page that will be displayed within the object. <script> .... chec ...

Submit button failing to fire upon clicking

I have recently started working with AngularJS and I'm facing an issue regarding ng-submit not getting triggered when trying to submit the form. Additionally, I am having trouble accessing $scope.user which is preventing me from posting to the server. ...

Unpredictable image sorting tool

Can someone recommend a plugin that functions similarly to the logos placement after the video section on this website: ? I really admire the way they have implemented it and would like to find something similar for my own project. ...

Conceal the footer using CSS while the slide is in focus

Trying to figure out a way to hide the footer when a specific container is active: For example, how can I hide the footer when the second and third items are selected as active? <div class="owl-stage"> <div class="owl-item"></div> & ...

Bootstrap image with absolute positioning overlapping columns

I'm facing an issue with absolute positioning of images in Bootstrap. When the screen size decreases, the second column is supposed to move below the first column but instead, it overlaps the image. Here's my current code: <div class="row"& ...

JavaScript will continue to process the submit to the server even after validation has been completed

My current challenge involves implementing form validation using JavaScript. The goal is to prevent the form from being sent to the server if any errors are found. I have made sure that my JavaScript function returns false in case of an error, like so: ...

What is the best way to ensure that text only displays up to five lines and fully collapses using CSS or javascript/jquery?

Hello everyone, I have come across an issue. English is not my strong suit, but I will do my best to explain it thoroughly. The problem at hand is a design requirement in the draft that specifies showing up to five lines of text. If the text exceeds this ...