CSS 仿Excel表格功能

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>Spreadsheet form - www.codefans.net</title> 
<style> 
table.formdata { 
 border: 1px solid #5F6F7E; 
 border-collapse: collapse; 
} 
table.formdata th { 
 border: 1px solid #5F6F7E; 
 background-color: #E2E2E2; 
 color: #000000; 
 text-align: left; 
 font-weight: normal; 
 padding: 2px 4px 2px 4px; 
 margin: 0; 
} 
table.formdata td { 
 margin: 0; 
 padding: 0; 
 border: 1px solid #E2E2E2; 
} 
table.formdata input { 
 width: 80px; 
 padding: 2px 4px 2px 4px; 
 margin: 0; 
 border: 2px solid #ffffff; 
} 
.formdata input:focus { 
 border: 2px solid #000000; 
} 
</style> 
<script language="javascript" type="text/javascript"> 
function hilite(obj) { 
 obj.style.border = '2px solid #000000'; 
} 
 
function delite(obj) { 
 obj.style.border = '2px solid #ffffff'; 
} 
</script> 
</head> 
<body> 
<form method="post" action="spreadsheet.html"> 
<table class="formdata" summary="This table contains a form to input the yearly income for years 1999 through 2002"> 
  <caption>Complete the Yearly Income 1999 - 2002</caption> 
  <tr> 
    <th></th> 
    <th scope="col">1999</th> 
    <th scope="col">2000</th> 
    <th scope="col">2001</th> 
    <th scope="col">2002</th> 
  </tr> 
  <tr> 
    <th scope="row">Grants</th> 
    <td><input type="text" name="grants1999" id="grants1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="grants2000" id="grants2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="grants2001" id="grants2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="grants2002" id="grants2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  </tr> 
  <tr> 
    <th scope="row">Donations</th> 
    <td><input type="text" name="donations1999" id="donations1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="donations2000" id="donations2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="donations2001" id="donations2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="donations2002" id="donations2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  </tr> 
  <tr> 
    <th scope="row">Investments</th> 
    <td><input type="text" name="investments1999" id="investments1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="investments2000" id="investments2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="investments2001" id="investments2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="investments2002" id="investments2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  </tr> 
  <tr> 
    <th scope="row">Fundraising</th> 
    <td><input type="text" name="fundraising1999" id="fundraising1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="fundraising2000" id="fundraising2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="fundraising2001" id="fundraising2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="fundraising2002" id="fundraising2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  </tr> 
  <tr> 
    <th scope="row">Sales</th> 
    <td><input type="text" name="sales1999" id="sales1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="sales2000" id="sales2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="sales2001" id="sales2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="sales2002" id="sales2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  </tr> 
  <tr> 
    <th scope="row">Miscellaneous</th> 
    <td><input type="text" name="misc1999" id="misc1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="misc2000" id="misc2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="misc2001" id="misc2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="misc2002" id="misc2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  </tr> 
  <tr> 
    <th scope="row">Total</th> 
    <td><input type="text" name="total1999" id="total1999" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="total2000" id="total2000" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="total2001" id="total2001" onfocus="hilite(this);" onblur="delite(this);" /></td> 
    <td><input type="text" name="total2002" id="total2002" onfocus="hilite(this);" onblur="delite(this);" /></td> 
  </tr> 
</table> 
<p><input type="submit" name="btnSubmit" id="btnSubmit" value="Add Data" /></p> 
</form> 
</body> 
</html> 
 

 

posted @ 2014-08-10 10:05  商商-77  阅读(619)  评论(0编辑  收藏  举报