Trouble adjusting the width of the Bootstrap card-body

After exhausting all available resources such as documentations and Stack Overflow answers, I am still unable to resolve the issue. Here is a snippet of the code I have tried:

<meta name="viewport" content="width=device-width, initial-scale=1">

I have attempted various solutions like using @@meedia in the style and setting w-100 on the card body, but nothing seems to work. I need the entire application to maintain a normal width, so any assistance would be greatly appreciated. My development environment consists of Visual Studio 2022 with .NET 6.

Specifically, when launching the application on desktop and switching to mobile view by pressing F12, the length of the card-body extends beyond the screen size. I am trying to set the width of the card-body to match the mobile screen size.

The code snippet in question is as follows:

<div class="row">
<div class="col-sm-4">
    <div class="card bg-light w-100 p-0">
        <div class="card-body">
            <a class="nav-link text-dark" asp-area="" asp-controller="Oglas" asp-action="ProdajaKuce">Prodaja kuća</a>
        </div>
    </div>
</div>
<div class="col-sm-4">
    <div class="card bg-light w-100 p-0">
        <div class="card-body">
            <a class="nav-link text-dark" asp-area="" asp-controller="Oglas" asp-action="ProdajaStanova">Prodaja stanova</a>
        </div>
    </div>
</div>
<div class="col-sm-4">
    <div class="card bg-light w-100 p-0">
        <div class="card-body">
            <a class="nav-link text-dark" asp-area="" asp-controller="Oglas" asp-action="ProdajaNekretninaZaOdmor">Prodaja nekretnina za odmor</a>
        </div>
    </div>
</div>

Despite my efforts, the outcome remains unchanged.

https://i.sstatic.net/8Xlyq.png

Answer №1

The w-100 class ensures that the width of the element is set to 100% of its parent container, which in this case is defined by the col-sm-4 class. Bootstrap utilizes a grid system with 12 columns, dividing the content based on the col- classes. If you want each column to take up an entire row, simply use the col-12 class.

If you wish for the columns to occupy the full width on mobile but be three columns on desktop, you can combine the col-sm-12 and col-md-4 classes as shown in the example below:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="04666b6b70777076657444331e07081e">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

<div class="row">
  <div class="col-md-4 col-sm-12">
    <div class="card bg-light w-100 p-0">
      <div class="card-body">
        <a class="nav-link text-dark" asp-area="" asp-controller="Oglas" asp-action="ProdajaKuce">Prodaja kuća</a>
      </div>
    </div>
  </div>
  <div class="col-md-4 col-sm-12">
    <div class="card bg-light w-100 p-0">
      <div class="card-body">
        <a class="nav-link text-dark" asp-area="" asp-controller="Oglas" asp-action="ProdajaStanova">Prodaja stanova</a>
      </div>
    </div>
  </div>
  <div class="col-md-4 col-sm-12">
    <div class="card bg-light w-100 p-0">
      <div class="card-body">
        <a class="nav-link text-dark" asp-area="" asp-controller="Oglas" asp-action="ProdajaNekretninaZaOdmor">Prodaja nekretnina za odmor</a>
      </div>
    </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

Troubleshooting: Javascript success callback not executing upon form submission

A snippet of my JavaScript looks like this: $(document).ready(function(){ $("#message").hide(); $("#please_wait_box").hide(); $("#updateinvoice").submit(function(e){ $("#message").hide(); ...

Disable, Hide, or Remove Specific Options in a Single Dropdown Selection

A challenge I am facing involves creating a form with multiple select options that need to be ranked by the user from 1-8. However, I am encountering some difficulties in hiding, removing, or disabling certain select options. Below is an excerpt from my f ...

Positioning Images in Bootstrap 4

I'm encountering an issue with Bootstrap 4. The left box isn't aligning properly with the right box. This involves both HTML and CSS. How can I go about resolving this issue? <section> <div class="container"> <div class="row"& ...

Modifying Image Source on Hover Using Jquery

Is it possible to change the source of an image on hover and then back to the original source? For example, the name of the file always remains the same, but the number changes - 1 for the original and 2 for the hover. Thank you for any advice. Code: < ...

Embarking on a background operation in ASP.NET MVC 4.5

In ASP.NET MVC, I have successfully implemented a basic pdf uploader. However, I now need to process the uploaded documents in the background due to potentially long processing times. The user should be able to upload a document and then continue using the ...

Unable to alphabetically arrange buttons automatically

I am encountering a challenge with automatically sorting buttons alphabetically on my webpage. I am unable to determine the method for sorting these buttons using jquery or javascript, but my goal is to have them sorted automatically when the page loads. I ...

How to use Javascript, HTML5, and AngularJS to display and print a PDF document within a

I have a situation where I need to load a Base64 encoded PDF as a String from my server into JavaScript in my client application which is built using AngularJS and HTML5. The structure of my HTML code is as follows: <div id="printablePdfContainer"> ...

What can be done to resolve the slowdown caused by an Ajax request within the function?

I've implemented drag and drop functionality for saving images, but I'm facing an issue with getting an instant preview of the saved images. Whenever I try to send the image to the server using an ajax request, the image doesn't appear on th ...

What could be causing the overflow of the div element within my header?

I recently embarked on a personal project to create my own portfolio website using HTML, CSS, and JavaScript. As I was working on styling the header section with bright colors for visualization purposes, I encountered an issue where the green box was overf ...

Utilizing String.Format in constructing Regex Patterns: "The provided string was not in the expected format"

I'm currently developing a document-from-template engine. In certain instances, I need to match on Reg Exp groups and replace template text with content from a database. Initially, I hardcoded my RegExp like this: Regex r = new Regex(@"{DocSectionTo ...

Guide on updating Bootstrap 4 to Bootstrap 5 using Yarn

Is there a way to transition from Bootstrap 4 installed with Yarn to Bootstrap 5? ...

Troubleshooting issues with document.querySelectorAll in JavaScript

Can someone explain why document.querySelectorAll isn't functioning properly in this code snippet? I'm a beginner and could use some help. <p id="demo">This is a paragraph.</p> <h1 id="1demo"> Hello </h1&g ...

Changing position with flair in CSS

Is there a way to create a transition effect on an element when it changes position from static to fixed? I attempted using the code: transition: position 2s linear;, however, it does not seem to have any impact. Are there any other methods I could experi ...

Bullet points colliding with one another

Is there a way to display an unordered list with list items in two rows and multiple columns without the bullet points overlapping? I have tried adjusting margins, but is there a more elegant solution to this issue? The requirement is to maintain the bul ...

Ensure the following elements remain in place once an element has been concealed

Imagine a scenario where three elements are present in an HTML file, with one element (specifically the middle one, .div2) hidden from view. The goal is to reveal this hidden element (.div2) and hide the first element (.div1) upon clicking a button using j ...

Is there a way to style CSS Content to appear both italicized and bold?

As I work on my project, I am aiming to style the CSS content class in both italic and bold formats. Take a look at the code snippet below. div::before { content: "text"; color:black; } <div></div> My goal is to achieve this exclu ...

How do I use JavaScript to make each trigger execute a function that only impacts its own child elements?

As I delve into the world of Javascript, I find myself grasping the concepts bit by bit. However, there's one thing that's been puzzling me, something so basic that I can't seem to find a clear answer on. My challenge involves a sidebar wit ...

How to align text vertically in a cell alongside a button in another cell using Bootstrap

In my table, I have 3 columns of text and a fourth column with a button. The alignment of the text in the cells does not match the button text vertically due to the button having a vertical-align value of 'middle'. To align them properly, I curre ...

Complete Navigation Bar Expands Alongside Drop-down Menu

For my navbar, I am attempting to set a custom breakpoint at 1080px where it switches to a hamburger menu. However, when I click on a dropdown option, the entire navbar expands instead of just the dropdown area. @media (min-width: 1080px){ .navbar-expand- ...

Having trouble retrieving information from JSON when making a call to the server-side web service

Client-Side Code var pre = "{\"objEmployees\": {\"Employee\": [{"; var array = JSON.stringify(employee); var last = "}}"; var ArrayofObjects = pre + array + last; DoSort(ArrayofObjects); function DoSort(ArrayofObjects) { $.aj ...