The responsive design of the Bootstrap 4 cards I made doesn't hold up well when switching between different screen

After crafting some Cards utilizing bootstrap, html and css, I encountered an issue when resizing the screen as the cards don't adjust accordingly.

Prior to resizing, this is how they appear:

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

Upon inspecting and switching to iPad view, this is what it looks like:

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

Despite attempting a media query in my css file to address this problem, I have had no success. Could someone please advise me on what mistake I might be making? EDIT: My ideal scenario would involve having one card stacked on top of another when adjusting the screen size, while also maintaining spacing between them.

<div class="col-md-4">       
   <div class="ScoreCard">
      <div>
         <h3 style="background-color:@item.TitleColor"> @item.ReportName - @item.TitleColor  </h3>
       </div>
<div class="col-lg-4">
     <div style="font-weight:bold; margin-top:35px;">
         <h1>GrossAmountDue</h1>
     </div>
</div>
 <div class="col-lg-2" style="margin-top:35px;">
     if (Flag == 1)
       {
        <i class="fas fa-circle" style="font-size:30px; color:red; margin-left:15px;"></i>
       }                                      
</div>
<div class="col-lg-6">
    <div>
       <p style="font-size:20px; margin-left: 25px;">Audited </p>
       <p style="font-size:20px; margin-left: 25px;">Packages: Will go here</p>
       <p style="font-size:20px; margin-left: 25px;">Transactions will go here</p>
       <p style="font-size:20px;"Icon will go here</p>
     </div>
</div>
<div class="row">
   <div class="col-lg-12" style="margin-top: 5px;">
        <p style="margin-left:17px;">Text Here</p>
  </div>
</div>
</div>
</div>
//CSS
<style>
    .ScoreCard {
        background-color: orange;
        width: 500px;
        min-height: 200px;
        border: 15px black;
    }

    @@media screen and (max-width: 100px){
        .col{
            width: 50%;
        }
    }
</style>

Answer №1

Ensure your columns are enclosed within a row like this:

<div class="row">
    <div class="col-md-12 col-lg-4">
        <div class="card">...</div>
    </div>
    <div class="col-md-12 col-lg-4">
        <div class="card">...</div>
    </div>
    <div class="col-md-12 col-lg-4">
        <div class="card">...</div>
    </div>
</div>

This setup ensures that on small or medium screens, the column contents stack vertically, while on large screens they form 3 columns in a row.

REMINDER

Check that you are adjusting the col class in your media query, not just using col-md-4.

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

toggle the visibility of a div using an unordered list

One of my challenges involves toggling the visibility of a div (filter-panel--content) containing an unordered list when clicking on the label above it. #LABEL/DIV THAT CAN BE CLICKED AND TRIGGERS .click() <div class="filter-panel--flyout"> <d ...

Verify the authenticity of a date using the locale parameter in the Intl API

Seeking advice for validating inputfield based on locale argument. How to format dates differently depending on the specified locale? For example, if locale is 'en-uk' then date should be in mm/dd/yyyy format, but if locale is 'de-ch' i ...

Concealing columns in DataTables based on designated screen sizes

Issue I am facing a challenge with two DataTables — one with five columns and the other with four columns. My goal is to find a solution for hiding certain columns based on specific screen widths. Approaches I've Tested While resizing the browser ...

What is the best way to align the bottom of an element with the browser buttons panel on mobile devices?

When viewing the website on a mobile device, I noticed that the floating button is hidden behind the browser buttons panel. Is there a way to adjust the positioning of the element relative to the browser's buttons panel? I attempted using env(safe-ar ...

Failure to receive results from $.getJSON request

I am currently working on developing a web page that allows users to search and retrieve Wikipedia pages based on their search results. Below is the relevant HTML code for the search feature: <form class='search-form' onsubmit='return f ...

What is the best way to separate the date and time into individual components?

I have created a dynamic object that shows both the date and time. My goal is to figure out how I can separate the time portion from the date so that I can place it in its own HTML element and style it differently? JavaScript isn't my strong suit, e ...

Tips for including vertical lines within text boxes to distinguish elements

I've been working on a simple form using CSS and HTML, but I'm struggling to add vertical lines to separate my text from the radio buttons. Right now, I'm just using '|' to divide them, but it's not the most visually appealing ...

Can an FAQ accordion collapse the selected element when another element is clicked?

I recently started working on a FAQ accordion project from frontendmentor. The functionality works perfectly when clicking on a question to reveal the answer and clicking again to hide it. However, I am facing an issue where if I click on one question and ...

Creating a personalized audio player using HTML

I have created a design for an audio player that I would like to implement using the HTML audio player element. https://i.sstatic.net/vJpGg.jpg When I tried <audio></audio>, it just displayed the default player: https://i.sstatic.net/nyNj8.j ...

Having trouble getting HTML/CSS div to align properly at the top of the page?

Apologies if this question seems redundant, but none of the answers I found have resolved my issue. All the margin, border, and padding settings are set to 0px. The main page div has margin-left and margin-right set to 15px on both sides. I have checked t ...

What's the best way to position a lone CTA at the center of the second row on a two-column layout using Elementor?

On my page, I am facing a challenge of adding a second section with a single Call to Action (CTA). The previous section on the same page consists of two CTAs placed side by side with a width set at 50% each. However, now I need to add a third CTA without i ...

Innovative method for layering two images on top of each other, similar to the design on popular social

I have been struggling to place an image on top of another image using bootstrap, but I can't seem to find a responsive solution. My goal is to achieve a design similar to this: https://i.sstatic.net/U3fqx.png I have noticed that all the answers prov ...

The div swiftly clicks and moves beyond the screen with animated motion

Here is a code snippet that I am working with: $(document).ready(function(){ $(".subscriptions").click(function (){ if($(".pollSlider").css("margin-right") == "-200px"){ $('.pollSlider').animate({"margin-right": '+ ...

What are the steps to retrieve the URL for submitting a form action?

I am facing an issue where the form action file is located in another directory, but some files need to be sent to this action file. How can I obtain the URL to send the action? -> The action needs to be directed to http://www.123456.com/ac.php Is t ...

Adjusting the alignment of text towards the right side

I've been experimenting with various positioning codes to shift the text to the right, but it seems that the CSS isn't recognizing the code properly. Screenshot: https://gyazo.com/6f9cc34d8ed6d33fde401b6317be3a3e .portal .icons a { positi ...

Create a Bootstrap-compatible responsive doughnut chart using Chart.JS that spans the full width of the

I am utilizing the Angular.js version of Chart.js, although the core functionality remains consistent. Currently, I have a basic doughnut chart placed inside a responsive Bootstrap container: <div class="row"> <div class="col-xs-8"> ...

Having trouble pinpointing the CSS/jQuery conflict and resolving it

Take a look at this page: At the top right of the website, you'll find a search box. However, it appears to be poorly designed. On this page, you can see the normal and desired behavior: (click on 'advertenties' to view the jquery effect). ...

jQuery Validator - emphasize dropdown selection in Internet Explorer

I am currently utilizing the validator plugin for jQuery, which adds a red border to invalid fields by applying a border style to the css class "error". However, I am encountering an issue with dropdowns (select) in Internet Explorer, as they are not displ ...

Getting style information from a parent element in ReactJS involves accessing the parent component's CSS properties

Is there a way to automatically change the color of text inside a button component based on the color of the button itself? I'm trying to access the parent element's color in my text component. Here's what I have: const MyText = (props) => ...

Tips on modifying the color of three distinct tooltip arrows

I managed to give 3 tooltips different colors using JavaScript and data-toggle like this <span class="tooltipjs" data-toggle="sin-datos" data-placement="right" data-original-title="some text">A</span> $( ...