Bootstrap grid. Instead of moving to the next row, scroll horizontally when the content overflows

Here is the code snippet:

<div class="row shochatgroup">
  <div  *ngFor="let message of messages" class="col-auto">
    <button *ngIf="message.state.attributes.shochatpaid > 0 && message.state.attributes.shochatpaid < 5" class="paidshowchat1-4 btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
    <button *ngIf="message.state.attributes.shochatpaid > 4 && message.state.attributes.shochatpaid < 9" class="paidshochat5-9 btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
    <button *ngIf="message.state.attributes.shochatpaid > 8 && message.state.attributes.shochatpaid < 20"  class="paidshochat10-19 btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
    <button *ngIf="message.state.attributes.shochatpaid > 19 && message.state.attributes.shochatpaid < 50" class="paidshochat20-49 btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
    <button *ngIf="message.state.attributes.shochatpaid > 49 && message.state.attributes.shochatpaid < 99"  class="paidshochat50-99 btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
    <button *ngIf="message.state.attributes.shochatpaid > 99" class="paidshochat100plus btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
  </div>
</div>

And here is the corresponding CSS:

.shochatgroup{
  overflow-x: auto;
  white-space: nowrap;
}

However, this is the unexpected resulthttps://i.sstatic.net/SsNV6.png

I came across this discussion on Stack Overflow, but I'm still trying to grasp the difference between my code and theirs: Horizontal scrollable div's in a bootstrap row

Answer №1

It appears that there may be an issue with your code or CSS causing the .shochatgroup class to not display properly. Make sure that white-space: nowrap; is applied correctly, and check for any conflicting styles or floating elements that may be affecting the layout.

.shochatgroup{
  overflow-x: auto;
  white-space: nowrap;
}
<div class="row shochatgroup">
  <div  *ngFor="let message of messages" class="col-auto">
    <button *ngIf="message.state.attributes.shochatpaid > 0 && message.state.attributes.shochatpaid < 5" class="paidshowchat1-4 btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
    <button *ngIf="message.state.attributes.shochatpaid > 4 && message.state.attributes.shochatpaid < 9" class="paidshochat5-9 btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
    <button *ngIf="message.state.attributes.shochatpaid > 8 && message.state.attributes.shochatpaid < 20"  class="paidshochat10-19 btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
    <button *ngIf="message.state.attributes.shochatpaid > 19 && message.state.attributes.shochatpaid < 50" class="paidshochat20-49 btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
    <button *ngIf="message.state.attributes.shochatpaid > 49 && message.state.attributes.shochatpaid < 99"  class="paidshochat50-99 btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
    <button *ngIf="message.state.attributes.shochatpaid > 99" class="paidshochat100plus btn" [ngbTooltip]="message.state.body"  triggers="click:blur">${{message.state.attributes.shochatpaid}}</button>
  </div>
</div>

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

observing numerous directories in Sass

Is there an efficient way to monitor multiple directories in sass using a shell script? This is what I currently have in my shell script: sass --style compressed --watch branches/mysite/assets/css/sass:branches/mysite/assets/css & sass --style compre ...

Using Material-UI to add a pseudo class '::before' with component class properties

I attempted to utilize a pseudo class for the mui-app-bar but did not have success. I've researched this issue on various platforms without finding a solution. Below is how my component is currently structured: const styles = (theme: Theme) => cre ...

Ways to align a bootstrap 4 row both vertically and horizontally in the center amidst other rows

Assume there is a main menu followed by three rows. The first row should be at the top and the third at the bottom, while the second row needs to be centered both vertically and horizontally. As you scroll down, the main menu should be able to hide while ...

What is the best way to incorporate classes into <li> elements within WordPress?

I'm currently in the process of building my WordPress theme from scratch, but I've run into a roadblock when it comes to adding custom classes to the < li > tags alongside those that are automatically generated by WordPress. Below is the co ...

The left margin class in Bootstrap seems to be having trouble functioning properly within a React

Navbar <div className="collapse navbar-collapse" id="navbarSupportedContent"> <ul className="navbar-nav ml-auto"> <li className=&quo ...

Arranging the rows and columns of a table in optimal alignment

I am currently facing an issue with two tables. The first table consists of 2 rows and 4 columns, with the first column spanning 2 rows. However, in the visual representation, the last 3 columns are misaligned with the rows. How can this alignment be corre ...

Spinner loading animation not showing correctly

Even though it shows up when I hover over and inspect, the image remains completely invisible. It's saved in the same folder and I believe all the file names are correct, but for some reason, it's just not working as expected. Any help would be g ...

Using JavaScript to dynamically load Cascading Style Sheets based on the current

I am trying to dynamically load different CSS files based on the current date (season). I attempted to tweak an image script that I found on Stack Overflow, but it didn't yield the desired result. Could someone please guide me on where I might be ma ...

Two liquid level divs within a container with a set height

I hesitated to ask this question at first because it seemed trivial, but after spending over 3 hours searching on stackoverflow and Google, I decided to give it a shot. The issue I'm facing can be found here: http://jsfiddle.net/RVPkm/7/ In the init ...

Aligning text vertically to the top with material UI and the TextField component

Seeking guidance on adjusting vertical alignment of text in <TextField /> const styles = theme => ({ height: { height: '20rem', }, }); class Foo extends React.component { ... <TextField InputProps={{ classes: ...

What are the benefits of incorporating various custom fonts through @font-face?

I feel like I must be overlooking something very simple. I have been using a single custom font with a normal font face: @font-face { font-family: CustomFont; src: url('CustomFont.ttf'); } Everything works perfectly when I use this font ...

Is it possible to include a border/stroke on a Raphael picture?

Currently, I am attempting to enhance a Raphael image element by adding either a border, stroke, or drop shadow. My end goal is to create an animated glowing border effect. Previously, I successfully implemented this on traditional HTML elements using Java ...

What are the essential files needed in Kendo UI Core for a mobile app?

Several months ago, I created a trial Kendo mobile app but now I want to verify it using the most recent version of Kendo UI Core. In my previous project, I referenced the following files: <link href="../styles/kendo.common.min.css" rel="stylesheet" / ...

Centering multiple floated divs using bootstrap

Looking for some help with a bootstrap panel design. I am trying to align a heading title to the left and a select element along with a date range input to the right of the panel heading, vertically aligned in the middle. While I have made progress on this ...

Show an HTML email message on a webpage without disrupting the existing page layout

Looking for a solution to display mail messages on a web page originating from an exchange server with various style elements that might interfere with the existing page layout. Attempting to load these mail messages within a div results in the style elem ...

Can adjusting the viewport by using touch controls alter the size of the viewing screen?

When I tried to zoom in on a webpage using touch instead of the keyboard shortcut Ctrl +, I noticed that the elements stayed the same size but the screen itself was enlarged. It seems like this method does not affect the size of the viewport. However, whe ...

Using Rowspan in Bootstrap 4 Beta 0 Grid System

Hey there, currently I'm working on an eCommerce template using Bootstrap 4 Beta. While I managed to get it working smoothly on mobile devices, I've run into a snag on desktop. I can't seem to figure out how to keep the Buy Box positioned un ...

Tips for ensuring that the click event function properly for numerous elements sharing the same class

I'm currently working on adding a flip effect to multiple tiles whenever a user clicks on them as part of building a dashboard-style webpage. I am having trouble making the click event work for all tiles with the same class name. Even though all the ...

Adjust the code to enhance the functionality of web components in Sharepoint

I recently came across some code online that I'm trying to modify in order to add an expanding button next to a web part on my Sharepoint site. However, the problem is that by default, all web parts are already expanded and require a click to collapse ...

Styling an HTML table with two columns: one column displaying an image, and the other column containing information related to the image

I have a concept that involves creating a table with 2 columns. The left column will feature an image, while the right column will display data about the image in 6 rows. ________________________________ | |_______________| | | ...