Issue with flex container not extending full width of parent container when overflow-x is enabled

Having trouble with the children of a flex container not taking full width. I want the content to use "flex: 1 0 216px" and have a scroll bar appear when necessary for overflow-x. However, the ".row" div isn't reaching the edge of its parent ".container", causing background color and border issues. See simplified code below. Thanks!

.container {
  height: 100%;
  background-color: lightgray;
  overflow-x: auto;
}
.row {
  background: lightyellow;
  min-height: 48px;
  padding-top: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid gray;
  display: flex;
  align-items: center;
  flex-basis: 100%;
  width: 100%;
}

.content {
  flex: 1 0 216px;
}
<div class="container">
    <div class="row">
      <div class="content">Content</div>
      <div class="content">Content</div>
      <div class="content">Content</div>
      <div class="content">Content</div>
    </div>
    <div class="row">
      <div class="content">Content</div>
      <div class="content">Content</div>
      <div class="content">Content</div>
      <div class="content">Content</div>
    </div>
    <div class="row">
      <div class="content">Content</div>
      <div class="content">Content</div>
      <div class="content">Content</div>
      <div class="content">Content</div>
    </div>
</div>

Answer №1

It seems like there might be an issue related to the interaction between flex and overflow: auto, but I haven't delved too deeply into it yet. If the goal is simply to make .row elements full width without using width: 100%, you could try setting min-width: calc(4 * 216px);. This should work especially well since you have already assigned flex-shrink: 0 and flex-basis: 216px; to .content, ensuring that it will never be smaller than that size.

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

Implement Video Quality Controls for HLS.js and Video.js during Live Streaming

Exploring HLS.js (() => { var video = document.getElementById('video'); console.log('VIDEO', video); if (Hls.isSupported()) { var hls = new Hls(); hls.loadSource('https://te ...

The addition of one-page navigation in Angular 7 seems to be experiencing some glitches

I recently added a new menu option to my Angular 7 project, but it's not functioning correctly. I used Bootstrap 4 and followed this example from here. Can anyone help me figure out the correct way to implement this? Check out the sample on StackBlit ...

Dynamic CSS Class Implementation with KnockoutJS

Greetings, I am seeking assistance as I am new to KnockoutJS. I am working with a class named green-bar that I need to activate when two particular states are true. Unfortunately, the solution I came up with below is not functioning correctly, and I'm ...

Automatically resizing a multi-part CSS background based on content dimensions

My current CSS project has hit a snag that I can't seem to solve: There is a box on the left side of the site that contains three images - a top image, an optional and stretched middle image, and a bottom image. I want this left box to automatically ...

Bootstrap: Ensuring vertical stacking of columns on mobile devices for responsive design

Here is the code snippet I am working with: <div class='carousel'> <div class='data-ng-repeat='{{ repeat }}'{% endif %}> <div class='col-xs-12 col-sm-3 vdivide valign-wrap' data-ng-repeat=&apos ...

Enhancing the KeyValuePair by incorporating additional value or parameter

I currently have a List<KeyValue<string, int>> that I utilize in the View of one of my applications. While it functions as intended, I am interested in expanding it by potentially incorporating an additional parameter/value to the KeyValue pair ...

What is the best way to build a personalized discussion platform: employing tables, <ul> <li>, <dl> <dt>, or div elements?

Looking to create flexible columns and rows with borders on the left and right of each column. If one row in a column stretches more, the other columns in that row should also stretch accordingly. Came across liquid 2 column layouts and 3 column layouts, b ...

Finding the current HTML page URL in Ionic 2: A step-by-step guide

Can the URL of the current HTML page be obtained and then converted to PDF using the cordova-pdf-generator package? ...

Using Javascript to refresh an image and update a class within a DIV when another DIV is clicked

I have a code that is quite lengthy to share here, so I've created a demo on JSFiddle: http://jsfiddle.net/Emily92/5b72k225/ This particular code takes a random image and divides it into multiple sections based on the class applied to the div contain ...

What is the best jQuery library to add to my website?

I have included several jQuery scripts on my website for various functionalities such as sticky header, anchors, and animations. I am wondering if it is necessary to include all of them or if I can just include one or two? Here are the jQuery scripts I ha ...

Require assistance in getting a slider operational

Hello there! I could really use your assistance with this code. I have been trying to make it work using JavaScript, but I'm determined not to incorporate any external JS files. Here is the snippet of JavaScript code I am working with: "use strict"; ...

Easier JavaScript for numerous HTML elements

I am an aspiring JavaScript learner seeking advice. Currently, I am working on a website that features numerous items with multiple images for each. I am utilizing JQuery to display a larger image when the user hovers over a thumbnail image. My query is ...

Troubleshooting border-left and td alignment problems in an HTML email displayed in Outlook 2013

Currently, I am facing a frustrating challenge while working on an HTML email signature. It seems to display perfectly in all email clients except for Outlook 2007, 2010, and 2013. The specific issue I'm encountering is with the alignment of the secon ...

Is it possible to adjust the CSS code linked to the HTML tag based on the specific webpage being viewed?

I am facing an issue with the homepage of my website, which uses Scrollmagic.js for smooth scrolling. In order for the sticky footer CSS to work properly on all other pages, the HTML tag needs to have a height of 100%. However, if I add this height value t ...

Issues with PHP not retrieving selected radio button values

Currently, I am using a PHP webpage to generate a list of all files with a .264 extension in a specific folder. Once the file is selected, it is then sent to a command for video playback on a display connected to the computer. I have encountered some diff ...

Displaying a variety of images in an HTML document can be achieved without the need to manually write out a separate tag

As a newcomer to HTML, I find myself faced with a challenge. I have a folder containing 100 images, all sharing a common prefix in their names but differing in the second part. For instance, some examples include: "content_diffusion_delay_AthfT@jurEYTgf" a ...

Hovering over a class list will modify various element IDs

Is there a way to change the height of an element with id = "header_nav" when hovering over the class "header_nav" li element? Here is the HTML Code: <div class="header_nav" id="header_nav"> <ul id="header_nav_mainmenu"> & ...

Organized Styled-components

Considering implementing styled-components in my application and questioning the best organizational approach. Usually, styled-components are associated with a particular component for increased reusability. However, what is the recommended method for us ...

Floating with Flex in Bootstrap 4: A seamless way to achieve

Is there a way to achieve this floating layout using Bootstrap 4 flex Grid? I've attempted to use the flex order function but encountered some issues. Have a look at my result: <div class="row align-items-start"> <div class="col-sm- ...

Replace the facebook plugin using JQuery libraries

Does anyone know how to remove the like button on top of the 'Like box' Facebook plugin using JQuery? I have imported the like box from Facebook and I want to eliminate this like button, but Facebook does not allow me to do so. Therefore, I am t ...