Spacing in Bootstrap4 Rows

I've been attempting to create some space between each row in my table, but so far I haven't had any luck with it.

I checked out the spacing guidelines in Bootstrap's documentation, and even tried adding p-x or m-x classes to my tbody and tr elements, but nothing seems to be working as expected. The only solution that somewhat works is adding a div within every td element, although it doesn't give me the desired outcome.

Just to clarify, I'm currently using the default Bootstrap4 CDN without any overrides.

Below is the code snippet:

<div class="table-responsive">
    <table id="example" class="table table-hover" style="width:100%; margin-top:4%">
        <thead class="thead" style="background-color:#5AC5F1;color:white;">
            <tr>
                <th scope="row">Event Name</th>
                <th scope="row">Start Date</th>
                <th scope="row">End Date</th>
                <th scope="row">Role</th>
                <th scope="row">Status</th>
            </tr>
        </thead>
        <tbody class="shadow-sm p-3 m-3 rounded">
            @foreach (var item in Model._EventsLines)
            {
            <tr>
                <td><a href="#myModal" class="myModal" data-toggle="modal" id="@item.EVL_id" onclick="GetEventsDetails(@item.EVL_id)">@item.EVL_nameEVT</a></td>
                <td>@item.EVL_dateStart.ToShortDateString()</td>
                <td>@item.EVL_dateEnd.ToShortDateString()</td>
                <td>@item.EVL_role</td>
                <td>@item.EVL_status</td>
            </tr>
            }
        </tbody>
    </table>
</div>

This is the type of layout I am aiming for:

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

For further reference, here is a fiddle containing the code: jsfiddle.net/7Lzdhe9m

Answer №1

Give this a shot

th {
  padding: 15px;
}
tbody td{
  background:#eaeaea;
}
table { 
  border-collapse: collapse; 
}

Answer №2

Give this a shot!

tr {
  margin: 10px 0;
  border-bottom: 2px solid black;
}
.table { 
  border-collapse: collapse;
  border-spacing: 0px 20px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />

<div class="table-responsive">
    <table id="example" class="table table-striped" style="width:100%; margin-top:4%">
        <thead class="thead" style="background-color:#5AC5F1;color:white;">
            <tr>
                <th scope="row">Event Name</th>
                <th scope="row">Start Date</th>
                <th scope="row">End Date</th>
                <th scope="row">Role</th>
                <th scope="row">Status</th>
            </tr>
        </thead>
        <tbody class="shadow-sm p-3 m-3 rounded">
            <tr>
                <td><a href="#myModal" class="myModal" data-toggle="modal" id="@item.EVL_id" onclick="GetEventsDetails(@item.EVL_id)">@item.EVL_nameEVT</a></td>
                <td>@item.EVL_dateStart.ToShortDateString()</td>
                <td>@item.EVL_dateEnd.ToShortDateString()</td>
                <td>@item.EVL_role</td>
                <td>@item.EVL_status</td>
            </tr>
                        <tr>
                <td><a href="#myModal" class="myModal" data-toggle="modal" id="@item.EVL_id" onclick="GetEventsDetails(@item.EVL_id)">@item.EVL_nameEVT</a></td>
                <td>@item.EVL_dateStart.ToShortDateString()</td>
                <td>@item.EVL_dateEnd.ToShortDateString()</td>
                <td>@item.EVL_role</td>
                <td>@item.EVL_status</td>
            </tr>
                        <tr>
                <td><a href="#myModal" class="myModal" data-toggle="modal" id="@item.EVL_id" onclick="GetEventsDetails(@item.EVL_id)">@item.EVL_nameEVT</a></td>
                <td>@item.EVL_dateStart.ToShortDateString()</td>
                <td>@item.EVL_dateEnd.ToShortDateString()</td>
                <td>@item.EVL_role</td>
                <td>@item.EVL_status</td>
            </tr>
        </tbody>
    </table>
</div>

Answer №3

Give this a shot and let me know if it meets your expectations.

table { 
    border-collapse: collapse; 
} 
th { 
    background-color:green; 
    Color:white; 
} 
th, td { 
    width:150px; 
    text-align:center; 
    border:1px solid black; 
    padding:5px 

} 

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

Tips for detecting HTML updates using Python requests

My goal is to monitor a page for updates while maintaining the same session and cookies, without sending a completely new request. How can I determine if there are HTML updates within my current request? The page will redirect but keep the same URL. This ...

The back-to-top feature is malfunctioning in the new Bootstrap 4 update

I've been working on adding a back-to-top button to my website using JavaScript in Bootstrap 4 with the Font Awesome icon set. It was functioning perfectly until I made some changes to the site, and now it's not working anymore. I'm pretty n ...

What is the process for determining the text direction of a website's title?

My website is having trouble displaying the title in the correct direction. I've attempted to add dir="rtl" to various tags like html, head, and title, but nothing seems to be working. In the English version I have "Select a service:" In the Arabic ...

Modify the background color of each word within the search bar

I've been attempting to colorize each word using jQuery and give them a colored background. I came across a solution, but it only seems to work for the HTML content, not the input field in the search bar. Below is an example of what I found: HTML So ...

Exploring the functionality of column and row in Bootstrap 5 modal form design

As I embark on creating my initial program using flask/python and incorporating Bootstrap 5 for the front end, I find myself facing a design challenge with a modal containing at least 6 form rows. What would be the optimal approach to aligning the form e ...

Rotating the transform causes the div to be pushed beyond the screen boundaries and renders

html, body { margin: 0; padding: 0; overflow-x: hidden; } /*HEADER*/ #header { background: blue; background-attachment: fixed; background-size: cover; width: 100vw; height: 100vh; } .btn-1, .btn-2, .btn-3 { background ...

Is there a way to stop users from altering form values on a webpage by using the "inspect" tool in their browser?

Currently, I am developing an application using node.js and handlebars as the view engine. One issue I am facing is that when a form is submitted, it inserts data into the database. The problem arises because the form passes values that are hidden from the ...

mapping buttons to images based on dynamic conditions

In my folder, I have over 1000 files. Using opendir, readdir, and is_dir, I can display the thumbnails of these files in my browser. Each thumbnail also has a corresponding button assigned to it. What I'm looking to do now is delete the 500th image wh ...

Enhance the appearance of div elements in GWT/HTML with custom styling

I am relatively new to GWT and have been exploring various options, but I have not yet found a solution to my issue. The challenge at hand involves developing a function schedule system in GWT, where I am working on designing the frontend. We currently ha ...

Navigational tabs have been implemented in multiple independent sets, eliminating the need for multiple scripts to manage hiding content on click events

In a previous inquiry, I sought guidance on achieving a specific tab functionality like the one depicted below: https://i.stack.imgur.com/s2Gm8.png The query led to an insightful suggestion from @BradleyCoupland, who provided the following code snippet: ...

Creating a CSS container with a uniquely shaped rounded triangle/arrow design

I would like to create a container background with a rounded arrow design. The arrow should always stretch to the full width of the container and be able to adjust its height dynamically (I can use JavaScript if needed to adjust the height). Here's a ...

Page Time Tracker: Monitor Your Website's Performance

How can we determine the amount of time a user spends on a webpage using C# code? Are there any available open source projects in .NET that enable us to track the time spent? ...

"Stunning Broth: Retrieve elements from a list without the need for comma

I am attempting to extract a list of cities from a webpage using Beautiful Soup The current output is: MonroeMatthewsWaxhawIndian Trail, Matthews What I want is: Monroe, Matthews, Waxhaw, Indian Trail, Matthews This is the HTML: <div id="current_tab ...

Eliminate a specific element from the dataset

My question revolves around a data array used to populate three drop down <select> boxes. How can I eliminate duplicate values within the drop downs without affecting the array itself? For example: data = { firstbox_a: ['grpA_1','gr ...

Tips for enhancing the presentation of JSON information

I recently ventured into the world of JSON and JS, managing to create a JSON file to showcase data using .onclick event. While I have successfully generated and displayed the JSON data on screen, my next goal is to present it in a table format for better c ...

Emptying the AnyChart (Javascript) container prior to generating new charts

I have been utilizing the anychart JavaScript library to generate a pie-chart from my data, which is dynamically pulled whenever a user modifies a dropdown selection. Below is the code snippet I am employing for this purpose: var stage = anychart.graph ...

When using JavaScript, an error may occur that says "Cannot read property 'style' of null," but strangely, this issue disappears when the code is copied and

I seem to be encountering an error in my codepen and I can't figure out what I'm doing wrong. It appears that I may have misplaced something, but I would greatly appreciate any help or explanation of my mistake. function on() { document ...

Creating a JQuery statement to conditionally change CSS values

Is there a way to determine if a div element with a CSS class of "x" has a height set to "auto"? If so, I would like a jQuery script to remove the CSS class "a" from all elements with the class "y". If not, the script can remain unchanged. Thank you. ...

The leaking of angular-material CSS onto other divs is causing unexpected styling

I am having trouble incorporating Angular Material's md-autocomplete into my angular application. I have already customized the CSS being used in my application, but when I add the Angular Material CSS, it messes up the entire page. Even when I tried ...

Text Separation Within a Singular JSON Object

Currently, I am offering my assistance as a volunteer to develop a fast AngularJS App for a non-profit organization. Although I have successfully set up Angular, the main issue I am encountering has to do with parsing JSON data. The JSON object that I am ...