现在的位置: 首页 > 综合 > 正文

CSS 仿Excel表格功能

2017年12月19日 ⁄ 综合 ⁄ 共 5092字 ⁄ 字号 评论关闭
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head> 
  4. <title>Spreadsheet form - www.codefans.net</title> 
  5. <style> 
  6. table.formdata { 
  7.  border: 1px solid #5F6F7E; 
  8.  border-collapse: collapse; 
  9. table.formdata th { 
  10.  border: 1px solid #5F6F7E; 
  11.  background-color: #E2E2E2; 
  12.  color: #000000; 
  13.  text-align: left; 
  14.  font-weight: normal; 
  15.  padding: 2px 4px 2px 4px; 
  16.  margin: 0; 
  17. table.formdata td { 
  18.  margin: 0; 
  19.  padding: 0; 
  20.  border: 1px solid #E2E2E2; 
  21. table.formdata input { 
  22.  width: 80px; 
  23.  padding: 2px 4px 2px 4px; 
  24.  margin: 0; 
  25.  border: 2px solid #ffffff; 
  26. .formdata input:focus { 
  27.  border: 2px solid #000000; 
  28. </style> 
  29. <script language="javascript" type="text/javascript"> 
  30. function hilite(obj) { 
  31.  obj.style.border = '2px solid #000000'
  32.  
  33. function delite(obj) { 
  34.  obj.style.border = '2px solid #ffffff'
  35. </script> 
  36. </head> 
  37. <body> 
  38. <form method="post" action="spreadsheet.html"> 
  39. <table class="formdata" summary="This table contains a form to input the yearly income for years 1999 through 2002"> 
  40.   <caption>Complete the Yearly Income 1999 - 2002</caption> 
  41.   <tr> 
  42.     <th></th> 
  43.     <th scope="col">1999</th> 
  44.     <th scope="col">2000</th> 
  45.     <th scope="col">2001</th> 
  46.     <th scope="col">2002</th> 
  47.   </tr> 
  48.   <tr> 
  49.     <th scope="row">Grants</th> 
  50.     <td><input type="text" name="grants1999" id="grants1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  51.     <td><input type="text" name="grants2000" id="grants2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  52.     <td><input type="text" name="grants2001" id="grants2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  53.     <td><input type="text" name="grants2002" id="grants2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  54.   </tr> 
  55.   <tr> 
  56.     <th scope="row">Donations</th> 
  57.     <td><input type="text" name="donations1999" id="donations1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  58.     <td><input type="text" name="donations2000" id="donations2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  59.     <td><input type="text" name="donations2001" id="donations2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  60.     <td><input type="text" name="donations2002" id="donations2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  61.   </tr> 
  62.   <tr> 
  63.     <th scope="row">Investments</th> 
  64.     <td><input type="text" name="investments1999" id="investments1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  65.     <td><input type="text" name="investments2000" id="investments2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  66.     <td><input type="text" name="investments2001" id="investments2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  67.     <td><input type="text" name="investments2002" id="investments2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  68.   </tr> 
  69.   <tr> 
  70.     <th scope="row">Fundraising</th> 
  71.     <td><input type="text" name="fundraising1999" id="fundraising1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  72.     <td><input type="text" name="fundraising2000" id="fundraising2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  73.     <td><input type="text" name="fundraising2001" id="fundraising2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  74.     <td><input type="text" name="fundraising2002" id="fundraising2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  75.   </tr> 
  76.   <tr> 
  77.     <th scope="row">Sales</th> 
  78.     <td><input type="text" name="sales1999" id="sales1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  79.     <td><input type="text" name="sales2000" id="sales2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  80.     <td><input type="text" name="sales2001" id="sales2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  81.     <td><input type="text" name="sales2002" id="sales2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  82.   </tr> 
  83.   <tr> 
  84.     <th scope="row">Miscellaneous</th> 
  85.     <td><input type="text" name="misc1999" id="misc1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  86.     <td><input type="text" name="misc2000" id="misc2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  87.     <td><input type="text" name="misc2001" id="misc2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  88.     <td><input type="text" name="misc2002" id="misc2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  89.   </tr> 
  90.   <tr> 
  91.     <th scope="row">Total</th> 
  92.     <td><input type="text" name="total1999" id="total1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  93.     <td><input type="text" name="total2000" id="total2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  94.     <td><input type="text" name="total2001" id="total2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  95.     <td><input type="text" name="total2002" id="total2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  96.   </tr> 
  97. </table> 
  98. <p><input type="submit" name="btnSubmit" id="btnSubmit" value="Add Data" /></p> 
  99. </form> 
  100. </body> 
  101. </html> 

 

抱歉!评论已关闭.