Bootstrap card-body width extends beyond the boundaries of the card header and footer

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

In the card design, the header and footer are slightly less wide than the body, resulting in some white space on both sides. Is there a way to stretch the header and footer so they fill the entire width?

Thank you for any guidance.

Here is a snippet of the code:

<div class="container mt-3">

    <div class="row justify-content-md-center">
        <div class="btn btn-secondary btn-md">
            <%= link_to  "Edit User Profile", edit_user_path(@user.id), style: 'color:#FFFFFF' %>
        </div>
    </div>
    <h2 class="text-center mt-4">Articles</h2>

    <% @user.articles.each_slice(3) do |articles| %>
        <div class="row">
        <% articles.each do |article| %>
        
            <div class="card col-4 shadow rounded">
                <%= link_to  "", article_path(article.id), class:"stretched-link" %>
                <div class="card-header font-italic">
                    by <%= article.user.username %>
                </div>
                <div class="card-body mt-4 mb-5">
                    <h5 class="card-title"><%= article.title%></h5>
                    <p class="card-text"><%= truncate(article.description, length:100) %></p>
                </div>
                <div class="card-footer text-muted">
                    <small>Created <%= time_ago_in_words(article.created_at) %> ago, edited <%= time_ago_in_words(article.updated_at) %></small>
                </div>        
            </div>
        <% end %>
        </div>
    <% end %>
</div>

Answer №1

Instead of applying both the "card" and "col-4" classes to the same DIV element, consider structuring your code like this:

<div class="row">
    <div class="col-4">
        <div class="card">
            <div class="card-header">
                Title 1
            </div>
            <div class="card-body">
                Body 1
            </div>
        </div>
    </div>

    <div class="col-4">
        <div class="card">
            <div class="card-header">
                Title 2
            </div>
            <div class="card-body">
                Body 2
            </div>
        </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

The issue of the selection option not being cleared after being set to 0 persists in JavaScript

I am facing an issue where I need to reset the select option to `0` when another option is selected. I have tried the code below for this purpose. if (varALPO1MobNum == "0") { var selectElement = $(&apo ...

Troubleshooting jQuery Dropdown Menu Animation Bugs

Take a look at this interesting fiddle: https://jsfiddle.net/willbeeler/tfm8ohmw/ HTML: <a href="#" class="roll-btn">Press me! Roll me down and up again!</a> <ul class="roll-btns"> <li><a href="#" class="control animated noshow ...

The subsequent menu selection will be based on the chosen menu value

I am attempting to accomplish the following: https://i.sstatic.net/JffUWC02.png Essentially, I need a select options menu with labels where selecting an option will display a corresponding value. These values should then become labels for a second selec ...

Caution: The `className` property does not align with Material UI css which may cause issues upon reload

https://i.stack.imgur.com/MxAiY.png If you are facing the error/missing CSS, check out this video for a visual representation. While older versions of similar questions exist on Stack Overflow such as React + Material-UI - Warning: Prop className did not ...

Utilizing jQuery/Ajax to send an ID parameter to a PHP script

This code is where the user interacts. <html> <head> <title></title> <script src="jquery-1.9.1.js"></script> <script src="jquery.form.js"></script> </head> <body> <?php include 'con ...

Trying out basic form validation - Adjusting border color for an empty input

Currently, I am experimenting with a basic login form using PHP and testing it out on XAMPP in Chrome. Below is the code for the login form: <form action="login.php" method="POST"> <label>User: </label> <i ...

Can you set up an automatic redirect after a payment is made on paypal.me?

Is there a way to automatically redirect users to a "successful payment" landing page after they make a payment on paypal.me? While PayPal offers an "Auto Return" feature, I am uncertain if it is applicable for paypal.me or if there are alternative methods ...

What is the best way to align all of my content to the center in HTML?

In my web design class, I encountered an issue while creating a page. Currently, my page consists of a navigation bar and an image. I wanted to center both elements using CSS. display: block; margin-left: auto; margin-right: auto I applied this CSS to th ...

Creating Functional Tabs Using CSS and JavaScript

I've been experimenting with this code snippet, trying to get it to work better. It's still a work in progress as I'm new to this and have only customized it for my phone so far. The issue can be seen by clicking on the Projects and Today ta ...

Is there a way to embed an HTML5 page inside another HTML5 page?

I'm currently working on a basic static HTML5 app. At the moment, I have all my code on one long page with thousands of lines. Here's how I navigate to another page: <div data-role="content"> <label for="heading">History</la ...

Setting a border on a specific column in ag-grid is a simple task that can help you customize

I have a table where the first set of columns differs from the rest. I am looking to emphasize this distinction by adding a vertical border on the right side of the specific column to highlight it both in the header and rows. Our setup includes using the ...

Mastering the art of incorporating background image transitions and creating a seamless slider for navigation

Is there a way to create a navigation menu like the one on this theme? On this theme, when you hover over a menu item, the background image smoothly moves left or right to the item you are hovering on. If anyone knows of plugins that can achieve this eff ...

Are the results displayed in a vertical array format?

Being new to this world, I would greatly appreciate any assistance! I am working with Bootstrap checkboxes and trying to print them using jQuery's window.print function. However, the issue I am facing is that the array I create from the checkboxes d ...

Executing primary MongoDB operation using Mongoid

Currently, I am utilizing mongoid within a rails project. My API call retrieves client records in JSON format, represented as an array of hashes. users = api.get_users # Retrieves JSON In order to take advantage of Mongo's search, sort, and paginati ...

Issues with stationary navigation bars

Having trouble with the fixed navigation bar, as it appears slightly lower on section links. I want the navigation bar to be at the top so that the title text in sections is clearly visible. I attempted to add margin-top to the section, but the gaps were t ...

Why aren't the divs appearing on the page?

I have developed a JavaScript and PHP page where the script in the PHP page sends data to my SQL database. However, the result is not displayed on my home page. Here is the code snippet: function getVote(question_ID) { var option_ID = document.queryS ...

Evaluate the functionality of a mobile web application by running it in a mobile device's browser through localhost

I am in the process of developing a mobile web app and I want to test it on a real mobile device. Currently, the app is running on my local environment at localhost:8080. I need to access this app using the same hostname and port on my mobile device as wel ...

Ways to showcase documents from a directory in Django

Recently, I developed a Django application that includes a folder containing images. A new requirement has arisen where users need the ability to select an image from a dropdown menu. They will be prompted to provide the path to the folder, and the selec ...

Scrolling left and right, text floats atop the image

Trying to implement a rollover effect image using CSS. The initial state shows only the title, but upon hovering, a text overlay appears. Everything seems to be working well except that the text area extends off to the right. Also, there is scrolling up an ...

The challenge of incorporating various JavaScript formats into one cohesive system

I am encountering an issue with using two different forms - one for retrieving radio button selections and the other as a submission form. The problem is, I am unable to use both forms' actions simultaneously. <table id="newImageTable" border="1" ...