What is causing the cards to overlap on a tablet-sized screen?

Is anyone else experiencing issues with bootstrap cards overlapping on tablet views? I had to adjust the height and width in the HTML code as opposed to CSS. Check out my HTML code below:

<div  class="container">
<div class="update">
 <h5>UPCOMING EVENTS</h5>
<div class="row row-cols-1 row-cols-md-3 g-4">
 <div class="col">
   <div class="card" style="width:300px">
     <img src="images/football.jpg" class="card-img-top" alt="..." style="height:200px; width:300px">
     <div class="card-body"  >
       <h6 class="card-title  " >CARIBBEAN FOOTBALL</h6>
       <button type="button" class="btn btn-outline-warning  card_button" >VIEW MORE..</button>
     </div>
   </div>
 </div>
 <div class="col">
  <div class="card" style="width:300px">
    <img src="images/football.jpg" class="card-img-top" alt="..." style="height:200px; width:300px">
    <div class="card-body">
      <h6 class="card-title ">EVENT NAME</h6>
      <button type="button" class="btn btn-outline-warning card_button">VIEW MORE..</button>
    </div>
  </div>

 </div>
 <div class="col">
  <div class="card" style="width:300px">
    <img src="images/football.jpg" class="card-img-top" alt="..." style="height:200px; width:300px">
    <div class="card-body">
      <h6 class="card-title ">EVENT NAME</h6>
      <button type="button" class="btn btn-outline-warning card_button">VIEW MORE..</button>
    </div>
  </div>

 </div>
 
 </div>
</div>
</div>

Here is my CSS code:

 /* Medium devices (landscape tablets, 768px and up) */
@media only screen and (min-width: 768px) {}

.card {
width: 200px
}

.card-img-top {
height: 300px;
width: 100px;
border-radius: 20px;
}

For a visual of how it's appearing on tablet screens, click here

Answer №1

The media query seems to be ineffective...

@media only screen and (min-width: 768px) {}

The media query specifications should be enclosed within the curly brackets...

@media only screen and (min-width: 768px) {

  .card {
    width: 200px
  }

  .card-img-top {
    height: 300px;
    width: 100px;
    border-radius: 20px;
  }

}

Furthermore, any inline styles (style="width:300px") will always take precedence over the media query.

It is advisable not to use fixed (pixel) widths for responsive designs. Applying a fixed width to the cards may hinder them from fully utilizing the responsive (relative width) columns available.

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

The text remains static and does not adjust its size when the screen is

I'm currently utilizing the text-only carousel feature found at this jsFiddle link. Below is the code I am using for resizing: window.addEventListener("resize", resetCarousel); function resetCarousel(){ setCarouselHeight('#carousel-text&apos ...

What are some alternative ways to utilize jQuery siblings() without restricting it to the same parent element?

In the code provided below as Non-functional code [1], it will function correctly with siblings() to disable other input fields if their sum or amount exceeds a specified maximum value. This works effectively when all input fields are within the same paren ...

How can I make a div extend beyond the boundaries of a bootstrap card?

Working with bootstrap version 4 and devexpress. The dropdown section you see is a creation by devexpress. https://i.sstatic.net/8vdj6.png ...

JavaScript code for iframe auto resizing is not functioning properly on Firefox browser

I have implemented a script to automatically resize the height and width of an iframe based on its content. <script language="JavaScript"> function autoResize(id){ var newheight; var newwidth; if(document.getElementById){ newh ...

Update the formatting of the dates in the dateRangePicker

Utilizing a dateRangePicker, I am receiving dates in the format "mm-dd-yyyy". Below is my HTML code: <input type="text" name="TextDate" value="10/24/1984" /> Here is the script being used: <script> $(function() { $(&apos ...

Do not apply the css rule to the custom class

I've been attempting to apply a CSS rule to href elements while excluding a specific class (.nolink). .content a { border-bottom: 2px; } I discovered that the :not selector can achieve this, but for some reason I'm having difficulty implementin ...

What significance does the symbol "'" hold in the ng-style attribute?

Can someone explain the purpose of the " \' " in this code snippet? <div ng-style="{ \'cursor\': row.cursor }" Is there a reason why it can't be written simply as <div ng-style="{ cursor: row.cursor }" Here is ...

What Could Be Causing the Issue with My Submit Button's addEventListener Function?

At the initial stages of my project, I am encountering a puzzling issue with my addEventListener. Surprisingly, using onClick with the submit button yields the desired results and displays output in the console. However, attempts to implement addEventListe ...

Is it possible to achieve a height transition using CSS instead of relying on JavaScript

I created these custom cards using a combination of HTML, CSS, and JavaScript. However, I've noticed that the height transition animation is not as smooth as I'd like it to be, especially on certain pages. Is there a way to achieve this animation ...

Utilizing Django fixtures: Importing HTML content as JSON into a Text Field

Currently in the process of transitioning my website to Django from another content management system, I am facing challenges with importing HTML into Django using fixtures. The specific issue revolves around "Events", which is a model within my Django app ...

Switching PHP include on an HTML page using JavaScript

I've been attempting to modify the content of the div with the ID "panel_alumno" using a JavaScript function that triggers when a button is clicked. My goal is to display a different table each time the button is pressed, but so far, I haven't be ...

Woocommerce Dual Column Payment Portal

I prefer a two-column layout for the checkout process on www.narwal.shop/checkout Here is the code I added: /* Large devices (large desktops, 1200px and up) */ @media (min-width: 993px) { /* --------------------- WOOCOMMERCE -------- ...

MDL Tab loading Problem

When visiting my website at this link, which is powered by MDL from Google, there is a troublesome issue that occurs. The #harule tab briefly appears before disappearing. This tab should actually be hidden on the page until a user clicks on the harule tab ...

Problem with video tag getting stuck

Is there a method to have the video tag remain fixed to the top (or bottom from the element above the video tag)? Currently, when the window is resized, the video element moves away from the top (or bottom). Could this be due to the video tag attempting to ...

Displaying content generated by Html.Raw in MVC4 using JavaScript and AJAX is causing displacement of content within the <a> tags in the HTML

My project includes a feature where emails sent to a specific address are parsed, with attachments saved to the network and metadata stored in a database. If the serial number of a finished good matches the one included in the email, a note is generated an ...

Showcasing JSON data on an HTML site

Having trouble displaying my JSON response on an HTML page using jQuery and AJAX. Here is my code: JSON RESPONSE { "result": [ { "list_id": "3", "state": "yuoio", "zone": null, "name": " T. Oji", "phone": "0828 ...

CSS - Overlapping elements on smaller screens due to being stacked

I am encountering an issue with a column of elements stacked below each other in my code. Here is a simplified version of my implementation: <div style="position: relative; height: 100%;"> <div style="position: absolute;">Really long text h ...

The background image stubbornly refuses to stretch to the full width of the section container

Looking at my code example and the screenshot provided, it's clear that the image is not fitting into the container even when set to 100% width or utilizing other properties. Below you will see the code snippet: .about-us{ background-image: url(i ...

Is it possible for me to automatically add a line break following every image that is fetched from the Flickr API?

Hello there! I'm facing a little challenge with inserting a line break after each image that loads from the Flickr API. It's tricky to manipulate the style of data that hasn't loaded in the browser yet. I've experimented with using the ...

Unable to precisely reach the very bottom of the scrollbar

When trying to move to the bottom of the scrollbar, I seem to reach a bit higher than the actual bottom. https://i.stack.imgur.com/Vt83t.png Here is my code: ws.onmessage = function (event) { var log = document.getElementById('log') ...