Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Padding Between "display:table-cell" [closed]

Is there a way to place padding or a transparent border around the "cells" when one does display:table-cell? I would like the background to show up through this space, so I can't just set the border to white, and border-color:transparent doesn't work for me for some reason. I've checked w3schools and similar sites but I haven't been able to find this particular trait.

From user Praveen Vijayan: http://jsfiddle.net/geymU/

like image 268
user1152440 Avatar asked Mar 05 '12 16:03

user1152440


People also ask

How do you add padding between cells in a table?

Cell padding is the space between cell borders and the content within a cell. To set cell padding in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <table> tag, with the CSS property padding.

How do you put a space between a table and a div?

Make a new div with whatever name (I will just use table-split) and give it a width, without adding content to it, while placing it between necessary divs that need to be separated. You can add whatever width you find necessary.

How do you insert cell padding and cell spacing in HTML table?

You can apply both padding and spacing, as in the fourth and fifth examples. In order to place space in or around each cell (or both), place the padding and/or spacing attributes within the <TABLE> code.

What is padding in HTML table?

HTML Table - Cell Padding. Cell padding is the space between the cell edges and the cell content. By default the padding is set to 0.


2 Answers

Use border-spacing: 10px on the parent container.

In your case

#nav ul{
    display:table;
    width:100%;
    border-spacing: 10px;
}

You can also give top/bottom and left/right separately like border-spacing: 10px 20px;

like image 179
Starx Avatar answered Oct 27 '22 12:10

Starx


The space between cells is controlled by the border-spacing and border-collapse properties in the table.

#nav ul {
    display: table;
    width: 100%;
    background: yellow;
    border-collapse: separate;
    border-spacing: 12px 6px;
}
like image 28
Quentin Avatar answered Oct 27 '22 11:10

Quentin