Overlapping Bootstrap rows in small screens

I'm currently working on a frontend project using bootstrap 5, specifically utilizing the grid system to ensure responsiveness across different devices.

However, I've encountered an issue in my code that I can't quite figure out.

The problem arises when I have two rows within a container - everything looks good on desktop view, but on mobile, one row seems to overlap the other:

Desktop:

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

Mobile:

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

Any insights into what might be causing this?

To make the issue more apparent, I've included a condensed version of the code, with the second row using a background color to highlight the problem:

li {
  list-style: none;
  /* display: inline-block; */
}

.window {
  --items-number: 10;
  background-color: rgba(0, 0, 0, 0);
  display: flex;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  width: calc(var(--items-number) * 130px * 100);
  height: 180px;
  right: 0px;
}

.wraper {
  position: relative;
  margin: auto;
  width: 100%;
  overflow-x: hidden;
  border-radius: 2px;
}

.roulette-list {
  padding-left: 0;
  position: relative;
  display: flex;
  justify-content: flex-start;
  margin-bottom: 0;
}

.roulette-list li {
  border-radius: 0.8rem;
  width: 110px;
  height: 100px;
  font-size: 3rem;
  font-weight: bolder;
  color: rgba(255, 255, 255, 0.5);
  margin: 0 25px 0 0;
  
  display: flex;
  justify-content: center;
  align-items: center;

}

.roulette-list li:nth-child(even) {
  background-color: #262833;
  color: #fff;
}

.roulette-list li:nth-child(odd) {
  background-color: #b927ad;
  color: #262833;
}

...

Answer №1

The issue lies within the game-row-height class in the initial row

<div class="row gx-0 game-row-height">

In your CSS, you have set the row's height to 500px if the viewport width is at least 576px, which works fine as all the content fits within that height.

.game-row-height {
    height: 200px;
}

@media (min-width: 576px) {  
    .game-row-height {
        height: 500px;
    }
}

However, in the mobile viewport where the width is less than 576px, the row height is set to 200px which causes the content to overflow. The row for displaying bets uses the virtual 200px height of the first row as a reference for positioning, leading to "overlapping" like shown here

I recommend increasing the initial height in your CSS or removing the class altogether to allow the height to adjust based on the content and viewport. Since you are using Bootstrap, which is already responsive, removing the class would be the ideal solution.

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

Some CSS styles are not displaying correctly within an iframe

Let me start by clarifying that I am not looking to add extra CSS to the contents of an iframe from the parent document. My issue lies with a document that normally displays correctly but experiences styling issues when shown in an iframe. Whenever I searc ...

Utilizing Material-UI for CSS styling in a live environment

My application has a 'dashboard' feature that utilizes material-ui. Within this dashboard, other apps are called and rendered. While this setup functioned smoothly during development, I encountered issues once switching to a production build. The ...

What is the best way to create an interactive menu icon that includes dropdown options using MUI menu features?

i am looking to create a component similar to this https://i.sstatic.net/fwIB0.png currently, I am utilizing a material UI pop menu in my project below is the JSX code snippet <div className="navMenu" style={{ position: "relative" ...

Align a block vertically

Is there a way to perfectly center a div vertically? There are plenty of methods for horizontal alignment, but no matter what I attempt, getting vertical centering proves to be a challenge. body { vertical-align: middle;} No effect body {text-align ...

An example of using quotes within quotes is an HTML tag embedded within JavaScript code

Currently, I'm working on a JavaScript code where clicking assigns the function getImage the source of an image to be displayed later on the page. The issue I'm facing revolves around dealing with quotation marks. <img src="bill.jpg" class=" ...

Having difficulty extracting information from an HTML page using Swift

I'm attempting to convert data retrieved from an HTML page into a readable format, but the string urlContent is showing as nil even though the data received from the NSURLSession is not null. This is my approach: var city = "London" var url = NSURL ...

I'm having trouble getting the code to work properly after the "else" statement using both jQuery and Javascript. My head is

Being a newcomer to javascript and jquery, debugging and viewing log files seem like a challenge compared to php. Any help from experienced individuals would be greatly appreciated. Although my code mostly works fine, I'm having trouble with the if/e ...

Avoiding the repetition of CSS animations during Gatsby page hydration

I am facing an issue in Gatsby where I have an element with an initial CSS animation. It works perfectly when the static site loads, but after hydration, it keeps repeating. Is there a way to prevent this from happening? Below is my styled components code ...

Difficulty arises when attempting to create JSON using the Array.push() function from the data received via Ajax. The generated JSON is not successfully populating the tbody element

I am facing an issue while populating my tbody with data using the code below: function adaptSelectedBanks(banks) { console.log(banks.length); $(function() { banks.forEach(function (ba) { var c ...

Issue with event.preventDefault() in Jquery not functioning as expected

My goal is to have the menu display and hide list items on click, with them being hidden by default. However, the issue I am facing is that the menu is generated in the admin section, so it automatically assigns a URL to each item. If I set the URL field o ...

Achieve visibility of sibling <div> without the need for JavaScript by utilizing the :checked CSS pseudo class

I've been attempting to implement the technique demonstrated in this article, but I'm struggling to achieve the desired effect of revealing new elements after a radio button is selected. .reveal-if-active { opacity: 0; max-height: 0; ove ...

Updating the color of tick marks on checkboxes

I have successfully updated the background color of my checkboxes using a custom function. However, the tick mark on the checkbox now turns black instead of remaining white. How can I keep the tick mark white while changing the background color? Here is t ...

Adjustable pseudo-elements derived from the size of the element

I have a unique feature in my web application that involves a span element with inner text and additional :before and :after pseudo-elements used as decorative lines on each side of the text. Check out this JSFiddle example to see exactly what I mean. .c ...

What is the recommended Vue js lifecycle method for initializing the materialize dropdown menu?

https://i.stack.imgur.com/cjGvh.png Upon examining the materialize documentation, it is evident that implementing this on a basic HTML file is straightforward: simply paste the HTML code into the body and add the JavaScript initializer within a script tag ...

hover effect with fading transition while mouse is still hovering

Is there a way to create a fade-in/fade-out effect on a div without the mouse needing to leave the area? Let me provide a clearer explanation: When the mouse enters the object The object gradually fades in Then, after a delay, the object fades out while ...

interaction & portal

I am currently managing a website that includes an iframe. Both the main site and the embedded site within the iframe are verifying the $_SESSION["login"]. Therefore, if the session expires, the user will be automatically logged out. The issue I'm fa ...

Limit on the number of rows/entries selected for each query and the maximum

Is it possible to set a limit on data selection in a drop-down list through coding? For example, having 3 selections in one drop-down list, with each selection limited to 20 people choosing from the data. <tr><td><label><font face=&a ...

Navigate through FAQ items with sliders using Owl Carousel 2 - Easily switch between different chapters

Exploring the creation of a FAQ section with individual carousels for each item. My primary objective is for the carousel to transition to the next chapter when advancing beyond the last slide (backwards navigation would be a future enhancement). I'v ...

Is there a workaround using jQuery to enable CSS3 functionality across all browsers?

Is there a way in jQuery to make all browsers act as if they have CSS3 capabilities? ...

Submitting a form in a Chrome packaged app

Exploring Chrome packaged apps for the first time and facing a common issue that involves two questions. Attempting to create a basic form to submit data to a server using Ajax and POST. However, running into the restriction of not being able to use inlin ...