What could be causing a full-width image render in Firefox when a nested flex item is centered?

My design involves nested containers with the display: flex; property. While Chrome/Edge display the item div correctly, in Firefox 110.0.1 the item div expands to fill the entire horizontal space within the wrapper (100% width).

Which CSS properties can I use to align the containers in Firefox as they appear in Edge? And which browser conforms better to the specifications?

Microsoft Edge:

https://i.sstatic.net/1eD7N.png

Firefox, image 1024×1024 px:

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

Firefox, image 200×200 px:

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

Code:

.wrapper {
  outline: aqua solid;
  outline-offset: -3px;
  background-color: black;
  color: white;
  display: flex;
  flex-direction: column;
  /* --> */ align-items: center;
  justify-content: center;
  width: 300px;
  height: 100px;
}

.item {
  outline: magenta solid;
  outline-offset: -13px;
  background-color: maroon;
  display: flex;
  place-content: center;
  place-items: center;
  max-height: 100%;
  max-width: 100%;
}

img {
  outline: gold solid;
  outline-offset: -23px;
  background-color: red;
  display: block;
  max-width: 100%;
  max-height: 100%;
}

body {
  background-color: darkgray;
  color: black;
}
<p>1024px wide image (scaled to 100px) in 300px wrapper:</p>

<div class="wrapper">
  <div class="item">
    i<img src="https://placekitten.com/1024/1024" alt="image">i
  </div>
</div>

<p>200px wide image (scaled to 100px) in 300px wrapper:</p>

<div class="wrapper">
  <div class="item">
    i<img src="https://placekitten.com/200/200" alt="image">i
  </div>
</div>

Answer №1

.container {
  border: aqua solid;
  border-spacing: -3px;
  background-color: black;
  color: white;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: center; 
  -ms-flex-align: center; 
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  width: 300px;
  height: 100px;
}

.card {
  border: magenta solid;
  border-spacing: -13px;
  background-color: maroon;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  place-content: center;
  place-items: center;
  max-height: 100%;
  max-width: 100%;
}

.image {
  border: gold solid;
  border-spacing: -23px;
  background-color: red;
  display: block;
  max-width: 100%;
  max-height: 100%;
}

body {
  background-color: darkgray;
  color: black;
} 

give it a shot and see if it works :)

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

Creating a unique blur effect on divs using HTML and CSS

Currently working on a website project and facing an issue where I need to apply Gaussian blur within a div. Although opacity can be adjusted, the challenge lies in blurring the text within the div. Seeking assistance for this matter <html> < ...

The scaling feature in CSS does not function properly in Internet Explorer 8

I've tried multiple approaches to transform the IE Matrix, but I'm facing an issue with the transform scale CSS not functioning in IE8. Code: .fture_box ul li.fture_img img{ width: 451px; height: 284px; display: block; margin: 0 0px 0 11px; pad ...

When the fullscreen modal is opened, the initial image displayed is not the same as the one that was clicked on

Seeking assistance: I've been struggling with a problem for quite some time now and could really use some help from you guys. My issue involves an 'AngularJS' webapp that retrieves posts from an 'FB page' via 'OpenGraph' ...

sticky bootstrap datepicker anchored to the top of the screen

Currently, I am working on a form that includes a date picker using the bootstrap datepicker In this setup, I have hidden the main bootstrap field and added three custom fields. When any of these fields are clicked, the calendar should open next to them. ...

How can we nest a div within the outermost parent element?

Consider a scenario where there are 3 different divs named grandParent, Parent, and Child. Although the parent's tag is placed inside the grandParent, due to the use of position: absolute; property, the parent ends up being displayed outside the grand ...

applying different styles to various elements

As a newcomer to the world of jQuery, I am attempting to achieve the following goal: I have several instances of a div, and for each instance, I randomly assign a class from a predefined list in order to modify certain attributes. While this process is su ...

Learn the method for attaching bargraph bars to the bottom without specifying a fixed height

I've been struggling to create a bar graph displaying visitor statistics. The challenge lies in attaching the bars to the bottom without knowing their exact height beforehand. Since my code uses percentages for the height and it fluctuates each time y ...

I need to remove the mobile view of my Angular application because it is not optimized for smaller screens

I have implemented Angular in my web application, but unfortunately it is not mobile responsive. In order to address this issue, I would like to disable the mobile view and instead display a message informing users that mobile view is not supported for t ...

Troubleshooting CSS navigation bar hamburger dilemma

Currently, I am facing an issue with a toggle button on my website. When I click on the hamburger menu, the navigation bar does not show up even though the toggle feature is working perfectly fine. I have tried combining different sources to solve this pro ...

Creating a bold portion of a string

My task involves dynamically creating <p> elements within a div based on the contents of my codeArray, which can vary in size each time. Instead of hard-coding these elements, I have devised the following method: for(i=1;i<codeArray.length;i++) ...

Update the height definition for the alert box

I need to adjust the height of my alert box, so I attempted the following: @alert-box: 60px; .alert-msg { height: @alert-box; margin: 20px 0px; } However, the outcome was In the image provided, it is evident that the text within the secon ...

Formatting tables

Below is the table structure that I have. I attempted to insert empty tds divs in order to achieve the formatting shown in the image, but I have not been successful. Any suggestions or ideas would be greatly appreciated. <table border="0" cellpadding=" ...

What is the best way to position an image using css?

I am looking to position an image on the left side of my homepage using CSS instead of HTML. However, I am having trouble figuring out how to make it work. The image I want to use is called Nobullying.jpg. HTML: <html> <head> <link re ...

How to automatically open JQuery Accordion panels when the page loads

My Accordion loads with the 1st panel open upon page load, but I am looking for a way to have the entire Accordion closed by default. Any help or suggestions on how to achieve this would be highly appreciated. Thank you for your assistance. FIDDLE http:// ...

Conceal/reveal div with initial partial visibility

http://jsfiddle.net/7RDBk/1/ At the moment, I am using slideUp and slideDown functions to hide and display a div. My goal is to have 25px of the div showing initially before expanding and going back to 25px when clicked. It seems like a simple task, but I ...

hidden behind the frame is a drop-down menu

I am currently working on a website that uses frames. The topFrame.php contains a menu with drop-down submenus, while the main frame displays the website content. However, I am encountering an issue where the submenu in the topFrame is getting hidden beh ...

Obtain the text that is shown for an input field

My website is currently utilizing Angular Material, which is causing the text format in my type='time' input field to change. I am looking for a way to verify this text, but none of the methods I have tried give me the actual displayed text. I a ...

Placing error notifications beneath my table rows for a more polished appearance

In the process of creating a review page for my app that showcases uploaded files, I've encountered an issue. Whenever a user uploads files with errors, I want to display a warning message below each specific file. Currently, I'm able to show the ...

Manually controlling line breaks in HTML text

When collaborating with designers, they often have strong opinions about word wrapping in the final HTML page. If I am working on a fixed layout (non-responsive) and the designer is not satisfied with how the text wraps, there are several options available ...

Switch div and expand/shrink the rest

Apologies for what might seem like a trivial question, but after working for a few hours now, I'm finding it difficult to wrap my head around this. My initial instinct is to handle this by manipulating the entire div structure with JavaScript, but I c ...