Generate a purposely filled css grid with excessive content

I am attempting to design a horizontal scrolling widget that resembles an image carousel but with text and icons.

This widget will contain multiple columns, but only one will be visible at a time while the others will have 'overflow: hidden'.

To ensure equal sized columns, I am exploring CSS-grid. For instance, using the following code to create three equally width columns:

display: grid;
grid-auto-columns: 1fr;
grid-auto-flow: column;

Yet, I am curious if there is a way to limit the grid itself to just one column wide so that each individual column retains one column width.

The desired outcome would show in a layout of three columns, where two columns overflowed and could then be concealed.

Uncertain if achieving this is possible without assigning a set 'px' width to the grid directly.

Answer №1

To achieve this, simply utilize 100%

.wrapper {
  display: grid;
  grid-auto-columns: 100%;
  grid-auto-flow: column;
  height:100px;
  overflow:auto;
}

.wrapper > div {
  background:red;
  box-shadow:0 0 0 2px inset #000;
}
<div class="wrapper">
  <div></div>
  <div></div>
  <div></div>
</div>

If you need to handle more columns and spaces, consider referring to: Responsive horizontal scrolling CSS Grid with fixed number of grid-items per breakpoint

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

Tips for making a rounded text box

How can I design a circular textarea where the text conforms to the shape? Here is my attempt, but I'm unsure how to keep the text inside the circle without relying on javascript. ...

Error: The EJS compiler encountered a SyntaxError due to an unexpected token || in the show component file located at /var/www/html

I'm currently working on a project inspired by Colt Steele's YelpCamp creation during his Udemy Web Dev Bootcamp. Everything was going smoothly until I tried to refactor some code towards the end of the course using YouTube tutorials. Now, whenev ...

What steps are needed to develop a proper HTML structure for this specific box in order to achieve the desired aesthetics?

Currently working on a box that includes various tags and an input field for adding new tags. The goal is to make this box resemble the tag form used on YouTube: https://i.stack.imgur.com/RSj2p.png This particular layout features a box with existing tags ...

Using bootstrap's center-block class, you can easily center

I'm attempting to center the content of a form. <div class="login-container"> <div class="center-block"> <form action="/joinChart" method="get"> <input name="username" id="username" type="text"><br><br> ...

Animating the change of background image position in jQuery

Struggling to change the background image position in jQuery animation? Need some assistance to troubleshoot it? Here is the code you are working with: CSS #pnav a{ background:url(http://www.us-bingo.com/images/Tickets/Solid-Color-Tyvek-Wrist-Ticket ...

jQuery tooltip anchored to the left side of the screen, ignoring all attempts to adjust its position

I have a jQuery tooltip that is supposed to hover over the table header, but it is displaying on the far left side of my screen with no formatting - just black text. I have attempted to use the placement and position jQuery attributes, but they do not seem ...

Attaching a $UI element to a <div> tag with JQuery may result in unexpected errors and issues

Attempting to connect SagePayments card elements to the paymentDiv. Followed their sample project for guidance, but encountering issues with populating the elements when running the program with a custom Sandbox merchantID and merchantKey. Chrome's de ...

Sketch a variety of numerical values in a circular formation

I was working on a number circle using the below fiddle, but I need it to always start from 0 at the top. How can I achieve this? Additionally, I would like to connect the numbers from the inner circle border to the number with a dotted line. How can I dr ...

Displaying a div when hovering over it, and keeping it visible until clicked

I want to display a div when hovering over a button. The shown div should be clickable and persistent even if I move the cursor from the button into the shown div. However, it should be hidden when moving out of the entire area. I'm unsure about how ...

Is there a way to search for text and highlight it within an HTML string using Ionic

Welcome everyone! I am currently utilizing Ionic to load an article from a local HTML string. <ion-content padding> <p [innerHTML]="url"></p> </ion-content> The 'url' variable contains the local HTML string. My goal ...

What is a simple way to center a box on a page without relying on margins?

I'm attempting to position a box in the center of the page without relying on margin. Here's what I've tried so far: .box-middle { vertical-align:middle; height:100px; width:100px; border:1px solid #ddd; } This approach h ...

What type of modelfield in django can store the duration of a video playback? Alternatively, how can a TimeField be used without an

It's surprising that I haven't found a solution on SO yet, but my current challenge involves storing information when a user taps/clicks on my video player. I am currently saving the current playback time in a TimeField as shown below: class Ta ...

Achieving a sticky scrollbar effect in CSS/JavaScript for scrolling within nested divs

I am trying to create a table with vertical scrolling for the entire table content. Additionally, I need two columns within the table to be scrollable horizontally, but the horizontal scrollbars disappear when the vertical scrollbar is present. How can I k ...

VueJs and the behavior of styling elements with inline CSS

Within my HTML, there is an <input> element that has the ability to change the background color of a <p> through an inline style. I conducted an experiment using two different methods to apply the style, and I encountered a peculiar behavior: w ...

When I update URLs in Django, my CSS breaks down

Recently, I encountered an issue on my website and found a solution by creating two separate HTML pages. However, when I modified the urls.py to differentiate the URLs for these pages, the CSS stopped working. Below is my code snippet and a detailed explan ...

What are some strategies for increasing my website's mobile responsiveness?

I've recently completed my online portfolio, and it appears to be functioning properly on desktop computers. However, I'm encountering responsiveness issues when viewing it on other devices or smartphones. Even though I have included the necessar ...

What is the reason for the delay in the firing of this document.ready event

Similar Question: Understanding window.onload vs document.ready in jQuery I seem to be encountering a problem: I have an image on my webpage that is relatively small. I also have a JavaScript function that dynamically sets the height of the left sideb ...

Retrieve a specific column value upon button click in HTML and JavaScript

I am faced with a table containing multiple columns, each row equipped with an edit button. https://i.sstatic.net/3S5VP.png Upon clicking the edit button, a modal view pops up where users can input values that are then sent via AJAX to my controller. ht ...

Is it possible to adjust the color of a pseudo class to align with the color of a different class?

Creating a unique 'block' element on a webpage named 'test-div' has been quite the challenge. Adding an additional class to test-div changes the background color, such as: test-div test-div-bg-bright-gold test-div test-div-bg-dark-blu ...

I encountered an issue while generating a crypto address on the Waves blockchain using the @waves/waves-crypto library in TypeScript

Encountering an issue with finding "crypto-js" in "@waves/waves-crypto". Despite attempts to uninstall and reinstall the module via npm and importing it using "*wavesCrypto", the error persists within the module's index.d.ts file. I am attempting to ...