Ways to create space between columns in a table

How can I achieve the table layout with a gap between columns, as shown in the design? Initially, I tried using border-collapse: separate but found it difficult to adjust borders in the tbody. So, I switched to collapse. Is this the right approach for creating this table, or should I explore other options? I searched for answers here but couldn't find a satisfactory solution. https://i.sstatic.net/rERWRP0k.png

I have implemented the following CSS:

.table-container {
  overflow: hidden;
}

[data-module=data-table] {
  border-collapse: collapse;
  border-spacing: 16px 0;
  table-layout: fixed;
}

[data-module=data-table] thead {
  margin-top: 40px;
}
...
<div class="table-container">
    <table data-module="data-table">
        <thead>
            ...
            </tr>
        </tbody>
    </table>
</div>

Answer №1

It appears that the content shown in the image accompanying this question is not a traditional table. Therefore, I recommend using a combination of div elements styled with CSS or Bootstrap to achieve the desired look.

In my solution, I have employed custom CSS within <div> tags. You can easily adjust properties such as font-family, font-size, and font-style to fit your specific requirements.

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Customized Design</title>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />

  <style>
    /* Custom CSS styles here */
  </style>
</head>

<body>
  <section>
    <!-- Content structure goes here -->
  </section>
</body>

</html>

Answer №2

In order to achieve the card look with a top border and rounded bottom border, you can remove the border-collapse: collapse; property. Once removed, you'll be able to use the CSS selector

[data-module=data-table] tr:first-of-type td.highlighted-column
for the top border with the necessary border-radius.

It seems like you are applying a similar style to another column as well.

Simply using the :last-of-type on the tr will give you the rounded border at the bottom of the card.

Answer №3

To creatively solve this issue, you can replicate the content and mask the unwanted portions using visibility: collapse;. Then, assign border-collapse: separate; to the main table housing the specified menu, as shown below:

.table-container {
  overflow: hidden;
}

[data-module=data-table] {
  border-collapse: collapse;
  border-spacing: 16px 0;
  table-layout: fixed;
}

[data-module=data-table] thead {
  margin-top: 40px;
}

[data-module=data-table] thead tr:first-of-type {
  border-bottom: 1px solid #242424;
  position: relative;
}

[data-module=data-table] thead tr:first-of-type th {
  color: #242424;
  font-family: "Bree Serif";
  font-size: 28px;
  ...
<div class="table-container">
  <table data-module="data-table" style="border-collapse: separate;">
    <thead>
      <tr>
        <th>Category</th>
        ...
...
      </tr>
    </tbody>
  </table>
  ...
</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

Remove and modify an li element that has been dynamically generated within a ul list

Currently, I am facing an issue in my code. I am dynamically creating li elements by taking input from an input box and then appending the data within li tags using jQuery. However, after adding the li element, I have included a delete button. The problem ...

Latest Version of Bootstrap (v5.0.1) - Issue with Hamburger Menu not Auto-closing when Clicking on Anchor Links on

Hello fellow developers, I'm facing an issue with the hamburger menu in a responsive layout using Bootstrap v5.0.1. The problem is that the menu doesn't automatically close when clicking on anchor links within the same page, even though collapse ...

Exploring carousel elements in Selenium using Python

As a user of Selenium, I am trying to loop through the games displayed in the carousel on gog.com and print out all the prices. Below are two random XPaths that lead to the information within the carousel: /html/body/div[2]/div/div[3]/div/div[3]/div[2]/di ...

Identifying input value changes without needing to manually enter key values

As an example: <input class="table-input" type="number" name="qty" [(ngModel)]="cpy.qty" matInput min="1" max="{{cpy.qty}}" where cpy represents an object that is constantly changing. Currently, I need to execute a certain operati ...

The JQuery function .html() fails to include all the HTML content retrieved from a JSON response

I've created some HTML using PHP's json_encode(), and it looks like this: ob_start(); if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); get_template_part( 'template-par ...

Stop CSS tooltip from overflowing outside of the page or window

One issue I am facing is with a CSS-only tooltip that uses a span to display the tooltip when hovering over a link. The problem arises when the link is positioned near the top or side of a page, causing the tooltip to extend beyond the edge of the page. I ...

Tips for getting flex-end to function properly in IE11

My attempt to implement justify-content: flex-end; for a DIV with hidden overflow content in IE11 was unsuccessful. Despite trying various approaches, I managed to create a basic code snippet that functions properly in Chrome but fails in IE11: .token- ...

Enhancing the appearance of specific text in React/Next.js using custom styling

I have a table and I am currently working on implementing a search functionality that searches for an element and highlights the search terms as they are entered into the search bar. The search function is functional, but I am having trouble with the highl ...

Database not receiving input data from AngularJS form submission

Having some trouble saving form data to the database using angularjs. Not sure what I'm doing wrong. Here's my HTML form: <form id="challenge_form" class="row" > <input type="text" placeholder="Challenge Name" ng-model="ch ...

Seeking Up/Down Arrows HTML numerical input feature specifically designed for iOS devices

I am having an issue with a number input box on iOS. I am utilizing jquery, kendo mobile, and HTML5 for this particular task. While the number input displays up and down arrows in the Icenium simulator, they are not showing on the iPad. I am seeking a sol ...

Securing a downloadable file with a password on a webpage

I am looking to create a webpage with a password-protected download option for a PDF. When someone clicks on the link, they should be prompted to enter a username and password. If they try to directly access the PDF at "www.example.com/~folder_name/abc.pdf ...

The image has max-height within a max-height container inside a fixed-height container

Here's the scenario: Can an image's max-height property be made to respect the fixed height of an ancestor element that is not its direct parent? I am aware that max-height requires a fixed height for calculation, so this query is distinct from ...

Strange problem with jquery/css animations when scrolling on the webpage

Here is the link to my page: The problem I am facing is that when the page initially loads, the animations do not work on most elements like the button below the video. However, when I scroll back up, the animations start working and then when I scroll do ...

"Placing the save button on top of a div - a step

I am trying to position a div with an ID below a save button in my HTML code. The current setup looks like this: <button id="item_new" data-action="create" class="floating-button mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button- ...

The twelfth child in the sequence is not functioning properly, although the others are working correctly

In my list, I have 12 elements and each element contains a div. My goal is to set different sizes for each div by using nth-child on the li element. However, the configuration for the 12th element does not seem to work correctly compared to the rest of the ...

Utilizing Selenium to automate a VBA loop for extracting HTML data directly into an Excel spreadsheet

I recently received help from the Stackoverflow community to scrape data from a webpage. It's an amazing group of people. They provided me with a function that imports data into Excel from a cell containing a URL. However, I'm facing issues becau ...

Chrome is the only browser displaying background images

My current issue is that the background image only appears on Chrome and not on Firefox or Edge. I am trying to have a different background image each time the page loads. $(document).ready(function() { var totalBGs = 5; var rnd = Math.floor(Math.ran ...

Charting Add-Ons for jQuery

Looking for suggestions on user-friendly graph drawing plugins compatible with jQuery. Currently developing a web application that will retrieve data from a remote database and present it through visual graphs... Explored jgcharts (the jQuery Google Chart ...

Having Trouble with the Background Video Scaling on My HTML Bootstrap Page for Mobile Devices

I have been working on an HTML background video page, and everything seems to be working perfectly on desktop. However, when it comes to mobile, the video does not cover the full screen. Only half of the video is visible on the mobile screen. Here is the ...

What is the reason for the request to accept */* when the browser is seeking a JavaScript file?

The html source appears as follows: <script type="text/javascript" language="JavaScript" src="myscript.js"></script> Upon debugging the http request using Fiddler, it is evident that the browser (Chrome) sends a GET request for myscript.js wi ...