Spacing between cells within a div table

Is there a way to add some space between cells in a div table without creating a solid grey block for the header? I've tried using background-clip:padding-box; padding: 14px; margin, but couldn't achieve the desired result. How can I create a few pixels gap between cells in a div table?

View the issue here

<div class="TableBox">
    <div>
        <div>Head</div> <div>Bigger Head</div> <div>Medium</div>
    </div>
    <div>
        <div>First</div> <div>Second</div> <div>Third</div>
    </div>
    <div>
        <div>First</div> <div>Second</div> <div>Third</div>
    </div>
    <div>
        <div>First</div> <div>Second</div> <div>Third</div>
    </div>
</div>

CSS:

.TableBox {display: table;}
.TableBox > div {display: table-row; border-spacing: 5px}
.TableBox > div >div {display: table-cell;  margin: 4px;}
.TableBox > div:nth-child(even){ color: red; }
.TableBox > div:nth-child(1){  background-color: #666666; color:white; border-spacing: 15px; background-clip:padding-box; padding: 14px; margin:0 20px}

Answer №1

You should apply the style border-spacing: 4px; to the .TableBox class, not the <tr>

Here is the fiddle link for reference: http://jsfiddle.net/EJBnm/1/

Answer №2

If you want to eliminate the need for margin, consider using a transparent border or white border instead: http://jsfiddle.net/jfsZg/

.ContainerTable > section >div {display: table-cell;  border:3px solid transparent}

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

Pass various chosen checkboxes to Java by utilizing jQuery and Ajax technology

I am struggling with sending multiple selected checkboxes from HTML to Java using jQuery/Ajax. The issue is that when I check the result in Java, instead of getting the values I selected (e.g., National, State), I get "activityRangeCBs[]". Here is the HTM ...

What are some clever ways to handle the transition of the display property?

While transitions for the display property may not work, I am exploring alternatives. I attempted using the visibility property but it didn't quite fit my needs. In my current setup, different text is displayed when hovering over an anchor tag by sett ...

Rotate CSS elements dynamically using jQuery

I'm trying to figure out how to change the rotation value of an image element in my code. Currently, the rotation is set to 315 degrees, but I want to change it to 0 when a click event occurs. Can anyone help me with this? ...

Aligning multiple 'divs' horizontally with different lengths of text

I have a set of 3 identical divs with fixed width. Each contains text of varying lengths and another nested div that is aligned to the right using float. When the text lengths are equal, they align perfectly. However, when the text lengths differ, the ali ...

Issue with CakePdf unable to properly render CSS styling

I am having issues with the CakePdf Plugin (CakePdf.DomPdf) as it is not recognizing my stylesheet. Despite copying my /View/Layouts/default.ctp to /View/Layouts/pdf/default.ctp, the pdf file generated does not reflect the styling. Could this be due to t ...

How to keep a centered div in a lengthy box using Bootstrap

After successfully creating a simple web page with a header containing both an image and text, followed by three blocks of content below it, the final addition I need to make is another block of text beneath the existing three. This new block should be cen ...

Displaying temporary data and removing it from an HTML table: Tips and Tricks

There are three input boxes and a button below them. When the button is clicked, I would like the input data to appear in an HTML table where I can delete records. I would greatly appreciate any assistance. Thank you in advance. ...

One effective way to redirect after a PUT request and display a one-time message

Here's what I'm aiming for in terms of desired behaviour: A user navigates to a password change web page. The user completes the form and it is sent via PUT request to our REST server. Upon successful completion, the user is redirected to their ...

Ways to make a background stretch infinitely in the x-axis

Currently, my header has a grey background with a width of 100% and a maximum width of 1000px. To extend the grey background beyond the 1000px limit, I have a separate div with an absolute position behind the header div. The issue arises when the user scro ...

What is the best way to cause a ball to collide with a triangle power-up on a canvas

I'm currently facing an issue with the power up feature in my game. Despite successfully displaying the shape on screen, the ball fails to speed up as expected upon collision with the shape. <html> <title>Level Selector</title& ...

My task is to extract the information from a webpage, display all the headings as categories in a dropdown menu, and then map all the sentences within each heading to their respective category

I've been tasked with extracting information from a webpage and organizing it into categories for a dropdown menu. Each category will have associated sentences listed underneath. For example, let's say we have a webpage structured like this: Fru ...

Incorporating stick-to-top scroll functionality using AngularJS and ng

I am trying to implement a 'sticky' scroll on dynamic content. My current working example can be found here. It seems to be working, but I encounter a small 'flicker' when new items are appended. This issue seems to be related to the se ...

I am working on customizing my WordPress website using three.js to add a background with a wireframe effect. However, I am facing difficulties in placing a sphere at the end of each line

I have a beautiful turquoise diamond and I want to incorporate a directional camera view in the background of a WordPress section. However, I am unsure how to achieve this. The issue I'm facing is that I created a wireframe over the diamond, but when ...

The HTML5 video tag is having trouble playing an .mp4 file that lacks an audio codec

I have been facing an issue while trying to upload a video to an Angular app using ng-file-upload. Everything works properly until I attempt to upload a .mp4 video without any audio codec. The video element appears, shows the correct duration in the contro ...

Finding the index of a table row based on its ID in TypeScript

Is there a way to retrieve the index of a specific row in a table using its ID without the need for clicking or looping through all rows? Here is an example of my HTML structure: <table id="tabId"> <tr id="a"> <td>ss</td> ...

Encountering a problem with the mouseup event

Hey there, I've got this code up and running smoothly but I'm looking to make a tweak. Is there a way to have the script halt on the mouse up event? Currently, it displays coordinates as you drag over an image, but I'd like it to only show ...

Tips for enhancing this CSS design to resemble a table

I am a beginner in working with CSS layouts for websites and I have implemented the following code that serves my purpose. Although it is currently functional, its functionality does not necessarily mean that it is well-written. Could someone review this ...

Transmitting messages from a cross-domain iframe to the parent window

In my parent component, I am embedding an iframe from a different domain. The iframe contains a button that when clicked, I need to capture the event and pass it back to the parent component. I have experimented with using window.postMessage and window.ad ...

While attempting to access a form response in Java, I have encountered an issue where the content does not load properly due to the delay in loading. This causes Java to retrieve incorrect information

Is there a way to delay the page load until the response is fully loaded? url = new URL("http://somesite.com/sompage.jsp?somefield=something"); URLConnection conn = url.openConnection(); BufferedReader br = new Buffe ...

How come the `table-fixed` class in Bootstrap isn't converting my table into a scrolling one?

I am having some trouble with making my table scrollable. I have around 550 rows in the table and I am using the `table-fixed` style from bootstrap, but it doesn't seem to be working as expected. Additionally, the `table-condensed` class is not regist ...