Ubuntu 24.04.1 LTS | Lataa ja asenna | Tutustu yhteisöön | Blogi | Yritysten tarjoamat palvelutUusimmat julkaisut: 24.04.1 LTS (suositeltu, 29.8.2024) ja 24.10 - Ubuntun 20-vuotisjulkaisu! (10.10.2024).
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><title>Seinfeld Foods</title><style type="text/css">table.Design11{ border:1px solid #c3c3c3; border-collapse:collapse; font-family: verdana, sans-serif; font-size: 8pt;}table.Design11 th{ border: 1px solid #666666; background-color: #88afe9; padding:3px;}table.Design11 td { border:1px solid #c3c3c3; background-color: #fdfdfd; padding:3px 8px;}</style></head><body><h4>Table class="Design11"</h4><table class="Design11" cellspacing="0"><TR><TH>id</TH><TH>type_id</TH><TH>name</TH></TR><TR><TD>189</TD><TD>8</TD><TD>Apple</TD></TR><TR><TD>190</TD><TD>8</TD><TD>Apple Pie</TD></TR><TR><TD>191</TD><TD>8</TD><TD>Avacado</TD></TR><TR><TD>192</TD><TD>8</TD><TD>Banana</TD></TR><TR><TD>193</TD><TD>8</TD><TD>Canned Fruit</TD></TR><TR><TD>194</TD><TD>8</TD><TD>Cantaloupe</TD></TR><TR><TD>195</TD><TD>8</TD><TD>Grape</TD></TR><TR><TD>196</TD><TD>8</TD><TD>Grapefruit</TD></TR><TR><TD>197</TD><TD>8</TD><TD>Hamptons Tomatoes</TD></TR><TR><TD>198</TD><TD>8</TD><TD>Macinaw peaches</TD></TR><TR><TD>199</TD><TD>8</TD><TD>Mangos</TD></TR><TR><TD>200</TD><TD>8</TD><TD>Melons</TD></TR><TR><TD>201</TD><TD>8</TD><TD>Nectarine</TD></TR><TR><TD>202</TD><TD>8</TD><TD>Oranges</TD></TR></table></body></html>
<html><head><title>Table with alternating rows</title><style>#alternate { border: 1px solid #666666; font-family: verdana, sans-serif; font-size: 8pt; margin: 0 10px;}#alternate th{ border-right: 1px solid #666666; background-color:#88afe9; padding:3px;}#alternate tbody tr td { padding: 3px 8px; border-right: 1px solid #ccddee;}</style><script type="text/javascript"><!-- // this function is need to work around // a bug in IE related to element attributes function hasClass(obj) { var result = false; if (obj.getAttributeNode("class") != null) { result = obj.getAttributeNode("class").value; } return result; } function stripe(id) { // the flag we'll use to keep track of // whether the current row is odd or even var even = false; // if arguments are provided to specify the colours // of the even & odd rows, then use the them; // otherwise use the following defaults: var evenColor = arguments[1] ? arguments[1] : "#fff"; var oddColor = arguments[2] ? arguments[2] : "#eee"; // obtain a reference to the desired table // if no such table exists, abort var table = document.getElementById(id); if (! table) { return; } // by definition, tables can have more than one tbody // element, so we'll have to get the list of child // <tbody>s var tbodies = table.getElementsByTagName("tbody"); // and iterate through them... for (var h = 0; h < tbodies.length; h++) { // find all the <tr> elements... var trs = tbodies[h].getElementsByTagName("tr"); // ... and iterate through them for (var i = 0; i < trs.length; i++) { // avoid rows that have a class attribute // or backgroundColor style if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) { // get all the cells in this row... var tds = trs[i].getElementsByTagName("td"); // and iterate through them... for (var j = 0; j < tds.length; j++) { var mytd = tds[j]; // avoid cells that have a class attribute // or backgroundColor style if (! hasClass(mytd) && ! mytd.style.backgroundColor) { mytd.style.backgroundColor = even ? evenColor : oddColor; } } } // flip from odd to even, or vice-versa even = ! even; } } }// --></script></head><body onload="stripe('alternate', '#fdfbf2', '#ccddee');"><h4>Table id="alternate"</h4><table id="alternate" cellspacing="0"><TR><TH>id</TH><TH>type_id</TH><TH>name</TH></TR><TR><TD>202</TD><TD>8</TD><TD>Oranges</TD></TR><TR><TD>203</TD><TD>8</TD><TD>Papaya</TD></TR><TR><TD>204</TD><TD>8</TD><TD>Peaches</TD></TR><TR><TD>205</TD><TD>8</TD><TD>Pineapple</TD></TR><TR><TD>206</TD><TD>8</TD><TD>Plantains</TD></TR><TR><TD>207</TD><TD>8</TD><TD>Plumbs</TD></TR><TR><TD>208</TD><TD>8</TD><TD>Prunes, Figs, any Dried Fruit</TD></TR><TR><TD>209</TD><TD>8</TD><TD>Raisins</TD></TR><TR><TD>210</TD><TD>8</TD><TD>Shredded Coconut</TD></TR><TR><TD>211</TD><TD>8</TD><TD>Strawberries with Chocolate Sauce</TD></TR><TR><TD>244</TD><TD>9</TD><TD>JujyFruit</TD></TR></table></body></html>
Vuorottelevat rivit on aika vaikea toteuttaa pelkällä CSS:llä, tässä on vaihtoehtoisesti tehty javascriptillä:
Osaisiko joku sanoa, mikä taulukon CSS-tyylissä menee väärin, ja miten korjata? Ymmärtäisin että tuo piirtovirhe johtuu reunan kollapsointiominaisuudesta, mutta mitä sille pitäisi tehdä.
border-collapse: separate;border-spacing: 0px 0px;
Edit: Mutta ehkä helpoiten saattaisi korjaantua, kun kokeilisi laittaa tuon "border-collapse: collapse;" tilalle nämä kaksi riviä:
table.Design11{ border: 1px solid #828282; border-collapse: collapse; font-family: verdana, sans-serif; font-size: 8pt; margin:5px;}table.Design11 th{ border: 1px solid #656565; background-color: #88afe9; padding:3px;}table.Design11 td { border: 1px solid #828282; background-color: #fbfbfb; padding:3px 8px;}
Miksi tuo teksti on noin hassun näköistä? Fontit?