What steps can I take to make the cards in bootstrap 5.3 responsive for mobile devices?

I'm struggling with my code and need some help. I've been editing it, but things seem to be getting worse instead of better. Specifically, I can't figure out how to set up my container, row, and columns in Bootstrap properly. My site uses cards with images and looks fine on desktop, but the layout breaks on mobile screens. Instead of scaling down to show one or two cards at a time, users have to scroll to see all the images. Any tips or suggestions would be greatly appreciated!

<!doctype html>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="keywords"content="breweryfx, Lancaster PA, best, beer, beer collectibles, bar, brewery, ale, lager, signs, trays, bottles, cans, coasters, labels" />
    <meta name="description" content="Buying and selling the best beer collectibles in Lancaster PA">

    <title>BreweyFX - Lancaster, PA</title>

    <!-- Rest of the head section omitted for brevity -->

</head>

<body>

    <header>
        <p>Content inside the header...</p>
    </header>

    <section>
        <p>Main content here...</p>
    </section>

    <footer>
        <p>Footer information...</p>
    </footer>

</body>

</html>

/* Additional CSS and other HTML files included as well */

Answer №1

Here's a suggestion:

html {
    height: 100%;
    margin: 0 6% 0 6%;
    padding: 0;
    border: 0;
    background-color: rgb(255, 174, 0);
}

body {
    margin: 0px auto auto auto;
    width: 100%;
    background-color: white;
    font-family: Georgia, Times, 'Times New Roman', serif;
    font-size: 1.7vw;
    font-weight: 500;
}

body>section>h1 {
    font-size: 4.5vw;
    padding-left: 4%;
    padding-top: .5%;
    margin-top: 0%;
    margin-bottom: 1%;
}

body>section>p {
    display: block;
    width: 80%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 1%;
    margin-bottom: 2%;
    text-align: center;
    font-size: 1.5vw;
}
footer {
    display: flex;
    color: white;
    justify-content: center;
    align-content: center;
    background-color: rgb(255, 174, 0);
}

.container {
    display: flex;
    justify-content: center;
    align-content: center;
}
.card {
    padding-top: 20px;
...
</nav>
  </header>
  <section>
    <h1><i>Coasters</i></h1>
    <div class="container">
      <div class="row">
        <div class="col-md-2 col-6 p-1">
          <div class="card h-100">
            <img src="Images/Coasters/dscn0990-296x296.jpg" class="img-size-coasters" alt="Del Mar Va Coaster">
            <div class="card-body">
              <h5 class="card-title">Del Mar Va</h5>
              <p class="card-price">$0.00</p>
            </div>
          </div>
        </div>
        <div class="col-md-2 col-6 p-1">
          <div class="card h-100" >
            <img src="Images/Coasters/Gibbons-894x894.jpg" class="img-size-coasters" alt="Gibbons Coaster">
            <div class="card-body">
              <h5 class="card-title">Gibbons</h5>
              <p class="card-price">$0.00</p>
            </div>
          </div>
        </div>
        ...
    </div>
    <p><a href="#bannerheader">Return to the top</a></p>
  </section>
  <footer>
    <p><i><b>Breweryfx.com</b> &#9830 Email: <a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="30595e565f705242554755424956481e535f5d">[email protected]</a>"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="630a0d050c230111061406111a051b4d000c0e">[email protected]</a></a> &#9830
            Phone: <a href="tel:717-368-7111">(717)-368-7111</a> &#9830 Address: <a
                href="http://maps.google.com/maps?oi=map&amp;q=677+Estelle+Drive,+17601">677 Estelle
                Dr, Lancaster, PA 17601</a></i></p>
  </footer>

</body>

</html>

For more details, check out the Bootstrap documentation: Grid cards

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

Does a browser's cache utilize storage for XMLHttpRequest responses?

I have a question regarding browsers in general, with a focus on Chrome. Imagine I have the following code snippet in my file, index.html: <img src='//path/to/foo.img'></img> The file foo.img changes on my server every hour. I woul ...

The issue with Angular version 15 p-dialogue not displaying HTML content when using a component selector

In my Angular application, I have an issue with rendering a component called urc.component from a different module (variance.module) inside another module (nursing-audit.module). The p-dialogue is opening and displaying the header correctly, but the urc.co ...

Version 5.3 of Bootstrap is now compatible with React JS 18. Additionally, you can now easily customize variables in SCSS by overwriting _variables

Greetings! I am looking to customize Bootstrap 5 variables. I copied the default variables file from this link. However, when I pasted the code into my custom file, I encountered the error shown in the screenshot below: https://i.sstatic.net/o8lLB.png T ...

Unusual default Nav bar positioning

When attempting to create a navbar, I encountered small gaps that seemed impossible to close. Adjusting margins only resulted in new gaps appearing on the opposite side. Even when trying to find a compromise, I ended up with gaps on both sides instead. It ...

The TreeView control displays as a <div> element, which results in an unexpected line break

I am currently working on designing a layout that includes an ASP.NET TreeView control on the left-hand side. However, I am facing an issue where the TreeView renders as a div, causing a line break. I have tried using display:inline, but it doesn't se ...

What is the best way to duplicate a CSS shape across a horizontal axis?

I am working on decorating the bottom of my page with a repeated triangle design. The image provided only displays one triangle, but I would like to extend it across the entire horizontal div. Here is a screenshot of my progress so far: https://i.stack.im ...

Discovering elements with multiple classes using watir-webdriver

In this scenario, let's consider an element like the one below: <div class="first_class second_class"></div> Now, we can locate it by its classes using the following methods: browser.div(class: 'first_class') browser.div(class ...

Extract ID for Bootstrap modal display

In my project, I am using a bootstrap modal that displays various strings. The challenge I am facing involves a loop of cards, each with a distinct 'id'. When triggering the modal, I want to show the corresponding id inside the modal itself, whic ...

Utilizing React to highlight buttons that share the same index value upon hover

I have some data in a JavaScript object from a JSON file, where certain entries have a spanid (number) while others do not. I've written React code to highlight buttons with a spanid on hover, but I'm looking for a way to highlight or change the ...

How can I adjust the container to fit the monitor's dimensions while still keeping the

I am currently facing an issue on my website where the main content div has a fixed height, causing it not to scale vertically on larger monitors. I attempted setting the CSS properties for the div to 'auto' in order to allow it to adjust to the ...

Is it possible to establish the page state upon loading (in the context of a GET request

At present, my navigation bar is set up to utilize AJAX for loading new pages and window.pushState() in order to update the URL when the AJAX call is successful. I've come to realize that it's crucial to push the page state during GET requests s ...

Rails 7 is missing the Toast element from Bootstrap 5

Having some trouble with implementing Bootstrap 5 Toast in Rails 7 for flash messages. Here is the code I am currently using: # application.html.erb <head> ... <%= javascript_importmap_tags %> <script> const toastElList = document.que ...

What is the best way to access a model attribute in every template?

My goal is to showcase the name of my model team in the website header. The Team model has a attribute named "name": class Team(models.Model): name = models.CharField(max_length=50, null=True, blank=True) In my template language, I am trying to disp ...

What is the best way to adjust the width of a column grid header in extjs

When adjusting the width of a vertical header in a grid to 50px, the header text disappears unless manually dragged to the left. How can I ensure the header text remains visible even with a smaller header size? Consider the following code snippet: { text ...

Angular Universal (SSR) 'Selectors were not applied as rules were not followed'

Steps to Reproduce: ng new testproject --style scss cd testproject ng add @ng-bootstrap/ng-bootstrap npm run build This issue is not limited to ng-bootstrap, it can occur with other frameworks like bootstrap or tailwind that use SCSS. Error Description: ...

I'm having trouble with jQuery recognizing the left-margin property. Is there a workaround for this issue?

I rarely use jquery, but I wanted to add animation to a side bar. The sidebar menu is 670px with a -670 left-margin. When the user hovers over it, I'd like the left-margin to change to 0px and reveal the hidden content. Upon mouseout, it should return ...

How can I create a box-shaped outline using Three.js?

As someone new to threejs, I have been trying to figure out how to render a transparent box around a symbol in my canvas. The box should only display a border and the width of this border should be customizable. Currently, I am using wireframe to create a ...

Issues have arisen with jQuery methods functioning properly within the Owl Carousel

My owl carousel displays rotating boxes that each contain a button. When I click the button in a box, I want to switch a class on a div within that same box. This functionality works perfectly until I wrap it in an owl carousel and initialize it. Once th ...

Ways to toggle the sliding of text on and off an image?

After spending some time experimenting with my code, I managed to get it working. Essentially, when a user hovers over an image, text now appears over the image. Since this is a gallery, I had to utilize $(this).children in order to target and display the ...

JavaScript code does not run when a page is being included

On my AngularJS-based page, I have included some additional HTML pages like this: <div data-ng-include src="includehtml"></div> Here is the JavaScript code: $scope.selectImage = function(id) {$scope.includehtml = id;} (I pass the HTML file ...