I currently have the following table definition:
<table border="1" cellspacing="0" bordercolor="#CEDFEF" cellpadding="1">
I am trying to transform it to CSS, using:
table{border:1px solid #CEDFEF;cellspacing = 0px;cellpadding = 1px}
The table doesn't render as it should, though. What am I doing wrong?
Secondarily, if I want to not apply this styling to one of my tables in specific, how do I do so?
I expect problem is with cellpading and/or cellspacing.
This is not valid CSS:
cellspacing = 0px;cellpadding = 1px
There are already some questions about that :
Set cellpadding and cellspacing in CSS?
Why are cellspacing and cellpadding not CSS styles
I hope this helps you.
Here you are & have a good year!
You need to optimize the tables in css with border, paddings and colors versus cellpadding and default stuff. Code for all tables in your site:
table {
width: 100%;
border-collapse: collapse;
border-bottom:1px solid #e1e1e1;
border-top:1px solid #e1e1e1;
margin-bottom: 10px;
background-color: #FFF;
}
table td {
padding: 4px 10px;
border-right:1px solid #e1e1e1;
border-left:1px solid #e1e1e1;
}
table th {
padding: 4px;
text-align: left;
border-right:1px solid #e1e1e1;
border-left:1px solid #e1e1e1;
font-weight: normal;
}
table tr {
border-left:1px solid #e1e1e1;
border-top:1px solid #e1e1e1;
}
and for tables with no common styling just add the class to the table tag (exapmle1):
table.example1 {
width: 100%;
border-collapse: collapse;
border-bottom:0px solid #e1e1e1;
border-top:0px solid #e1e1e1;
margin-bottom: 20px;
padding-bottom: 20px;
background-color: #FFF;
}
table.example1 td {
padding: 0px 0px;
border-right:0px solid #e1e1e1;
border-left:0px solid #e1e1e1;
}
table.exapmle1 th {
padding: 0px;
text-align: left;
border-right:0px solid #e1e1e1;
border-left:0px solid #e1e1e1;
font-weight: normal;
}
table.example1 tr {
border-left:0px solid #e1e1e1;
border-top:0px solid #e1e1e1;
}
Also you can customize many things with more classes...
table.exapmle1 td {
text-align: center;
}
table.exapmle1 td.left {
text-align: left;
font-weight: bold;
}
table.exapmle1 td.right {
text-align: right;
}
and add class to the td tag for example.
Hope this helps.
It is generally not possible to transform the table-related HTML attributes so that the exact appearance is preserved. The main reason is that the HTML attributes have vague definitions and different interpretations in different browsers, as you can see e.g. by viewing a page with the given attributes on IE and Firefox. It is not possible to replicate this browser-dependence in CSS.
The following stylesheet, which assumes that your markup has <table class=t>, tries to replicate a “typical” or “average” rendering of a table with the given attributes:
table.t {
border-collapse: collapse;
border: outset #CEDFEF 2px;
}
table.t th, table.t td {
border: inset #CEDFEF 2px;
padding: 1px;
}
It’s seldom useful to convert presentational HTML attributes to CSS. When designed new or completely rewritten documents, it is better to start from the desired appearance rather than some existing or hypothetical HTML attributes. For example, solid borders usually look better than the outset or inser borders that <table border> creates, and a padding of 1px is seldom appropriate (usually you want either no padding or a few pixels on left and right, none on top and bottom).
General info: Mapping presentational HTML to CSS. See also subsection Tables in section Rendering of the WHATWG HTML5 draft.
This is the another one way in CSS styling..!!
while styling many tables in html, we can follow this way..!!
Hope it is help full
In Css:
#list
{
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
width:100%;
border:dashed;
background-color:#CC0099;
border-bottom:1px dashed;
border-top:1px dashed;
border-collapse:collapse;
}
In Body section, simply we can give the name...!!
<table id="list">
Related
I have a dynamic table with 2px solid border in my web page that sometimes contains lots of rows. I am currently using page-break-before and page-break-after CSS properties.
The CSS code is as per below:
table { page-break-inside:auto }
tr { page-break-inside: avoid; page-break-after:auto }
table.table-bordered{
width: 100%;
border:2px solid black;
margin-top:20px;
border-collapse: collapse;
}
table.table-bordered td{
padding: 6px;
border:2px solid black;
margin-top:20px;
}
The main problem is, it is showing underline when page breaks.
How can I solve this issue?
Thanks in advance.
My right side table border goes way further then the last column(The light grey line is my border), see the image below:
This is the css code of the table:
table.tableizer-table {
font-size: 12px;
border: 1px solid #CCC;
font-family: Arial, Helvetica, sans-serif;
}
The td and th, see below:
.tableizer-table td {
padding: 4px;
margin: 3px;
border: 1px solid #CCC;
}
.tableizer-table th {
background-color: #1e73be;
color: #FFF;
font-weight: bold;
}
Html:
<table style="display:none;" class="tableizer-table" id="tableMonths">
This is what i do in JS:
document.getElementById('tableMonths').style.display = 'block';
Does any one knows why this problem occurs?
It looks like you have 'display: block' on the table somewhere else in your code, which is making it take up the full width. Try inspecting it and changing the value to 'inline'.
I am auto-generating the HTML output using KDB. I would like to avoid labeling the html with classes if possible because I'd rather not re-work the KDB code. I tried using first-child, but it didn't work. Any other suggestions?
KDB:
.util.html.t:{[t]
if[not type[t] in 98 99h; :"Result not a table type!"];
r:"<table cellSpacing='0' cellPadding='2'>";
r:r,"<tr class='title'>";
r:r,(,/){"<th>",x,"</th>"} each string cols t;
r:r,"</tr>";
r:r,(,/){"<tr>",((,/){
if[type[x]=type[""]; x:`$x];
if[not type[x]=type[enlist ""];
x:string x;
if[x like "*[0-9]%"; :"<td class=\"centeralignum\">",x,"</td>"];
];
if[type[x]=type[enlist ""]; x:"," sv x];
:"<td>",x,"</td>";
} each x),"</tr>"} each 0!t;
r:r,"</table>";
:r;
}
CSS:
h3 { font-size: 16px; font-weight: bold; font-family: Calibri }
body { font-size: 12px; font-family: Calibri }
tr.title { background: lightblue repeat-x left bottom; font-weight: bold; border: 1px solid #000000;}
th {border: 1px solid black;}
table { border: 1px solid black; border-collapse: collapse;}
table td {border-left: 1px solid black; border-right: 1px solid black; width:125px;}
table td:first-child {font-weight: bold;}
td.centeralignum {text-align: center}
HTML
<table cellSpacing='0' cellPadding='2'><tr class='title'><th>name</th><th>a</th><th>b</th><th>c</th></tr><tr><td>bob</td><td>1</td><td>4</td><td>7</td></tr><tr><td>anna</td><td>2</td><td>5</td><td>8</td></tr><tr><td>ray</td><td>3</td><td>6</td><td>9</td></tr></table>
Using the HTML and CSS on Firefox that you gave worked for me. I even toggled the first-child property to make sure that it was causing it which it was. The first-child property has been supported for quite a while but it is worth checking here to see if your browser supports it.
You can go into developer tools on your browser and select the element in the inspector to see the styles that are being applied. If they are being overridden they will have a strikethough and you can also toggle properties or add new ones in the developer tools to see how they change the display
I try to do a little forum to train a little on web design. How can I change that table design to have a 3 dimensions (3D) table ? Or if there is any solution to improve its design, that will be maybe better !
Otherwise, any criticism is welcome!
/* Tableaux -------------------------------------------------------------------------------------*/
table {
border-collapse: collapse;
}
pair {
background-color: #efefef;
}
tr.impair {
background-color: #fff;
}
th {
color: #D89845;
border: 1px solid #D89845;
padding: 5px;
font: normal 8pt verdana, helvetica, sans-serif;
}
td {
border: 1px solid #ddd;
padding: 5px;
font: normal 8pt verdana, helvetica, sans-serif;
}
PS: I will keep the best suggestion as validation of the subject.
Thanks in advance.
You can use box-shadow is the best solution to give any object a 3d look & feel.
box-shadow use browser specipic prefixes like -webkit, -o, -moz etc . Here I just gave the link where you can find out more about it & can study how it works. I also many times just created such type of objects that have just 3d feel.
Link to box-shadow.
Maybe you can do anything with this,
CSS:
.gridtable {
border:1px solid #000000;
height:149px;
width:342px;
overflow-x: scroll;
}
.fixedcell {
height:30px;
padding:0 2 0 2px;
background-color:#C2BFA5;
border-left:1px solid #E1E0D2;
border-top:1px solid #E1E0D2;
border-right:1px solid #8D8961;
border-bottom:1px solid #8D8961;
}
.gridcell {
height:30px;
background-color:#ffffff;
padding:0 2 0 2px;
border-right:1px solid #C0C0C0;
border-bottom:1px solid #C0C0C0;
}
Edit
Link to 3d effects : http://www.w3schools.com/cssref/pr_border-style.asp
I think an image best describes this: JS FIDDLE HERE: http://jsfiddle.net/fp2Ak/
What I want to do, is for those lines to actually touch. Each one is a span with a number in. within a td. Note: some Tds contain multiple spans, for example, 218 and 222. (you can see tr with faint blue lines.)
As you can see it does touch at one point, as this is the biggest element in the column (including header). But this is rarely the case. How would I stretch it to touch in ALL Cases.
You can suggest using someting other than span, but please note that I do need more than one thing in a td, and hence cant be applied to the td.
The CSS that governs most of this so far:
table.Timetable td , table.Timetable th
{
border-spacing: 0px;
padding: 0px;
}
.bookingStart, .bookingMiddle, .bookingEnd
{
background-color: white;
color: Black;
border-top: 2px solid black;
border-bottom: 2px solid black;
}
.bookingStart
{
border-left: 2px solid black;
}
.bookingEnd
{
border-right: 2px solid black;
}
Oh and preferabblly Id like to be able to pad the cells again, as the th clearly have been merged together.
JSfiddle of it here: http://jsfiddle.net/fp2Ak/
spans have to be floated in order to be affected by width, so you could do something like:
td span{float:left; width:100%; min-width:100%;}
or more accurately if I am understanding your css properly:
.bookingStart, .bookingMiddle, .bookingEnd
{
background-color: white;
color: Black;
border-top: 2px solid black;
border-bottom: 2px solid black;
float:left;
width:100%;
min-width:100%; /*some browsers like this better*/
}
Your should put your borders on the td's not the spans. This will allow you to also put some padding on the td's to make even the long numbers look good.