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/
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.
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.
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.
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.
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;
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With